aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Author Topic: Startup with PHP-Script  (Read 6178 times)

PsychoChris

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
Startup with PHP-Script
« on: November 18, 2005, 05:42:52 AM »

Hello,

i'm trying to start amuled by the PHP-command 'shell_exec' like this:

shell_exec("/usr/local/bin/amuled -f");

Unfortunately this doesn't seem to work and i can't figure out why. The output of 'shell_exec' looks like this:

amuled: OnInit - starting timer Initialising aMule Checking if there is an instance already running...

Can anybody help me? How could it be possible to startup amuled in a PHP-script?

Greetings & thanks in advance,
Chris
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Startup with PHP-Script
« Reply #1 on: November 18, 2005, 07:30:35 AM »

try if

amuled &

works instead of

amuled -f

I had reports lately that -f was not really doing what is was supposed to
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

PsychoChris

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
Re: Startup with PHP-Script
« Reply #2 on: November 18, 2005, 02:14:20 PM »

Hello stefanero,

even 'amuled &' didn't work. Any ideas why this doesn't work? Most things i want to do with amuled with PHP are easy to handle with amulecmd, but starting amuled turned out to be not as easy as i thought.

Greetings,
Chris
Logged

vdb

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 215
Re: Startup with PHP-Script
« Reply #3 on: November 18, 2005, 03:46:15 PM »

What's the user you are trying to start amuled with? If this user does not have a configuration directory, .aMule, with the amule.conf file present the daemon won't start.

If you start it like "amuled" it should produce a logfile in the .aMule directory, giving more clues as to what the error exactly is. If you start amuled detached (the -f option) the logfile will not contain information, since that is not flushed yet.
Logged
A waste is a terrible thing to mind.

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Startup with PHP-Script
« Reply #4 on: November 18, 2005, 04:29:28 PM »

Quote
Originally posted by vdb
What's the user you are trying to start amuled with? If this user does not have a configuration directory, .aMule, with the amule.conf file present the daemon won't start.

thats just not true sorry, how are you supposed to start the daemon the first time ;)
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

vdb

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 215
Re: Startup with PHP-Script
« Reply #5 on: November 18, 2005, 05:01:46 PM »

Aha, but it _is_ true, although I must admit I'm not entirely correct too  :)

This is what happens if you try the daemon the first time:
[blabla@bla blabla]$ amuled
amuled: OnInit - starting timer
Initialising aMule
Checking if there is an instance already running...
Credits: Failed to load creditfile
Credits: Created new RSA keypair
Loading temp files from /home/blabla/.aMule/Temp.

All PartFiles Loaded.
MuleUDPSocket: Created Server UDP-Socket at port 4665
ListenSocket: Ok.
MuleUDPSocket: Created Client UDP-Socket at port 4672

External connections disabled in config file
*** Server UDP socket (TCP+3) at 0.0.0.0:4665
*** TCP socket (TCP) listening on 0.0.0.0:4662
*** Client UDP socket (extended eMule) at 0.0.0.0:4672
Empty dir /home/blabla/.aMule/Incoming/ shared
General: CamuleDaemonApp::OnRun()

ERROR: aMule daemon cannot be used when external connections are disabled. To enable External Connections, use either a normal aMule or set the key"AcceptExternalConnections" to 1 in the file ~/.aMule/amule.conf

MuleUDPSocket: Shutting down Client UDP-Socket
Now, exiting main app...
aMule OnExit: Terminating core.
MuleUDPSocket: Shutting down Server UDP-Socket
aMule shutdown completed.

Ergo: It creates a config directory BUT fails to start because the default setting in the amule.conf file is incorrect....... If one does not edit the configuration file to enable external connections, one can try this very often without success. Also, if one starts the amuled detached, one will never find this error, since the logs aren't flushed. (btw, Kry, will this be fixed before the next release?)
Logged
A waste is a terrible thing to mind.

lfroen

  • Guest
Re: Startup with PHP-Script
« Reply #6 on: November 19, 2005, 09:29:01 PM »

I will consider to fix it.
Logged

PsychoChris

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
Re: Startup with PHP-Script
« Reply #7 on: November 21, 2005, 12:57:18 AM »

Hello,

thanks for the information. Now i understand the problem. So i would need to startup amuled as the user its supposed to run under. I will try this with sudo.

Greetings & thanks,
Chris
Logged

lfroen

  • Guest
Re: Startup with PHP-Script
« Reply #8 on: November 21, 2005, 06:23:44 AM »

Quote
I will consider to fix it.
After consideration the answer is "no".
Reason is following: if we choose to enable external connections automatically, we must choose password automatically as well. For amuleweb to work, 2 passwords are needed: 1 for connection with core, and second for user access. Even if we will set first to random value and write its MD5 hash to amule.conf and remote.conf; second, the user password must be available in plain-text form since user will enter it. This leads to predefined (or hard-coded) password - bad for security, considering that by now you can not change password thru amuleweb (but you can with remote gui).
Logged

Kry

  • Ex-developer
  • Retired admin
  • Hero Member
  • *****
  • Karma: -665
  • Offline Offline
  • Posts: 5795
Re: Startup with PHP-Script
« Reply #9 on: November 21, 2005, 07:58:51 AM »

What about a text-mode query to activate EC and a password query the first time amuled is run?
Logged

lfroen

  • Guest
Re: Startup with PHP-Script
« Reply #10 on: November 21, 2005, 05:24:33 PM »

What about case when first time run activated with -f (fork to background and detach from terminal) ? IMHO correct solution is following:
1. amule detect first-time run
2. Random password generated for EC and written to amule.conf and remote.conf
3. amuleweb set to predefined password "Pass"
4. On a first access to webpage, user is prompted to change password

Since (4) is not implemented yet, the whole thing will have to wait.
Logged

PsychoChris

  • Jr. Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 66
Re: Startup with PHP-Script
« Reply #11 on: November 22, 2005, 12:05:22 AM »

Hello,

after trying a bit around my only solution to run amuled by a php-script is to give the user through which apache webserver is working a shell and let this user set the HOME-var by configuring sudoers to the one which amuled uses. If think this is more than unconvenient and it would be very interesting to know what security issues this brings up that the webbrowser-user can have a shell-login.
Does anyone have a better idea? Every suggestion is welcome.

Greetings,
Chris
Logged

vdb

  • Full Member
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 215
Re: Startup with PHP-Script
« Reply #12 on: November 22, 2005, 11:18:54 PM »

The answer to your question is, apart from searching the forum or wiki ;):
1) Select the user you want to run amuled from
2) Run the the daemon once as this user, amuled or amuled -f, doesn't make a difference, it will fail anyway. But it will create the right config directory in the home directory of your user. (the user needs to have a home directory.....)
3) Go to the .aMule directory, and edit the amule.conf file to set AcceptExternalConnections = 1 and set a password in the ECPassword field. How to create this password, please look at the wiki, don't know it off hand. It must be done by using md5 hashing, not just plain text.
4) Start the daemon again, it should work now.

Now you should be able to use all kinds of starting the daemon, as long as it is as the user where you have a .aMule/amule.conf file. And have lots of fun.
Logged
A waste is a terrible thing to mind.