Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong path in start scripts of binary installer invoked by regular user #4258

Closed
badlop opened this issue Jul 17, 2024 · 1 comment
Closed

Comments

@badlop
Copy link
Member

badlop commented Jul 17, 2024

When ejabberd is installed using a binary installer invoked as root, the start scripts are perfect:

$ sudo ./ejabberd-24.06.49-1-linux-x64.run
...

$ grep "DIR=" /opt/ejabberd-24.06.49/bin/ejabberd.init
DIR=/opt/ejabberd-24.06.49/bin

$ grep "Exec" /opt/ejabberd-24.06.49/bin/ejabberd.service
ExecStart=/opt/ejabberd-24.06.49/bin/ejabberdctl foreground
ExecStop=/bin/sh -c '/opt/ejabberd-24.06.49/bin/ejabberdctl stop && /opt/ejabberd-24.06.49/bin/ejabberdctl stopped'
ExecReload=/opt/ejabberd-24.06.49/bin/ejabberdctl reload_config

However, when the same installer is invoked as a regular system user, the start scripts include wrong paths:

$ ./ejabberd-24.06.49-1-linux-x64.run
Running without superuser privileges (installer wasn't invoked
with "sudo"), cannot perform system-wide installation this way.
Continue anyway? (y/n) [n] y
Install ejabberd below /home/badlop/opt? (y/n) [n] y

The following installation paths will be used:
- /home/badlop/opt/ejabberd-24.06.49
- /home/badlop/opt/ejabberd (existing files won't be modified)
...

$ grep "DIR=" /home/badlop/opt/ejabberd-24.06.49/bin/ejabberd.init
DIR=/home/badlop/home/badlop/opt/ejabberd-24.06.49/bin

$ grep "Exec" /home/badlop/opt/ejabberd-24.06.49/bin/ejabberd.service
ExecStart=/home/badlop/home/badlop/opt/ejabberd-24.06.49/bin/ejabberdctl foreground
ExecStop=/bin/sh -c '/home/badlop/home/badlop/opt/ejabberd-24.06.49/bin/ejabberdctl stop && /home/badlop/home/badlop/opt/ejabberd-24.06.49/bin/ejabberdctl stopped'
ExecReload=/home/badlop/home/badlop/opt/ejabberd-24.06.49/bin/ejabberdctl reload_config

Apparently this problem only affects ejabberd.init and ejabberd.service; fortunately ejabberdctl is perfect. And this only affects when the *.run installer is invoked as a regular user. That would explain why this got undetected for so many time.

I would say that the problem is in the setup script generated by make-installers and included in the binary installers, maybe next to those lines:

if [ "\$code_dir" != '$default_code_dir' ]

@prefiks
Copy link
Member

prefiks commented Jul 17, 2024

So i think this is result of that if section you pointed and next if section being applied one after another, i think we just apply that second one to value that we applied before.
If that's the case maybe substituting those two ifs with this:

	if [ "\$code_dir" != '$default_code_dir' ]
	then
		sed -i "s|$default_code_dir|@CODE_DIR@|g" \
		    "\$code_dir/bin/${rel_name}ctl" \
		    "\$code_dir/bin/$rel_name.init" \
		    "\$code_dir/bin/$rel_name.service"
	fi
	if [ "\$data_dir" != '$default_data_dir' ]
	then
		sed -i "s|$default_data_dir|@DATA_DIR@|g" \
		    "\$code_dir/bin/${rel_name}ctl" \
		    "\$code_dir/bin/$rel_name.init" \
		    "\$code_dir/bin/$rel_name.service" \
		    "\$data_dir/conf/$rel_name.yml" \
		    "\$data_dir/conf/${rel_name}ctl.cfg"
	fi
        sed -i "s|@CODE_DIR@|\$code_dir|g;s|@DATA_DIR@|\$data_dir|g" \
		    "\$code_dir/bin/${rel_name}ctl" \
		    "\$code_dir/bin/$rel_name.init" \
		    "\$code_dir/bin/$rel_name.service" \
		    "\$data_dir/conf/$rel_name.yml" \
		    "\$data_dir/conf/${rel_name}ctl.cfg"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants