Re: Start a command on boot with superuser access
Reply #2 –
Someone can correct me on this, but I believe rc.local is generally considered unnecessary and most openrc distributions don't provide it. First of all, for packages like this, you need to check the PKGBUILD. Looking at what is in the AUR, you can see that it's specifically built with systemd meaning that you'll need to change the configuration. It may be sufficient to simply remove the "--with-systemd" line. It may not be. For example, you may want to enable pam. You'll probably have to read the documentation to determine what configuration is right for you. Whatever the case, you'll definitely need to alter the PKGBUILD since it is written specifically for systemd systems. Alternatively, you could just compile it locally yourself, but AUR is fairly convenient and it's probably easier just to slightly modify the PKGBUILD.
Additionally, you'll want to use an initscript for proftpd instead of messing with rc.local. All the init scripts on your system should be in /etc/init.d. Of course, this package isn't in Artix, so you'll have to get the init script from somewhere. Your best bet is probably just to get the one from gentoo and then modify the paths a bit for Arch-based systems. Here's what I have.
#!/usr/bin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
extra_started_commands="reload"
depend() {
need net
use logger dns mysql postgresql antivirus
}
check_configuration() {
if [ ! -e /etc/proftpd/proftpd.conf ] ; then
eerror "To execute the ProFTPD server you need a /etc/proftpd/proftpd.conf configuration"
eerror "file. In /etc/proftpd you can find a sample configuration."
return 1
fi
/usr/bin/proftpd -t &>/dev/null
if [ $? -ne 0 ] ; then
eerror "The ProFTPD configuration file /etc/proftpd/proftpd.conf is invalid! You have to"
eerror "fix your configuration in order to run the ProFTPD server. For more information"
eerror "you may execute the ProFTPD configuration check '/usr/bin/proftpd -t'."
return 2
fi
}
start() {
checkpath -d /run/proftpd
[ "${RC_CMD}" = "restart" ] || check_configuration || return 1
ebegin "Starting ProFTPD"
start-stop-daemon --start --quiet \
--exec /usr/bin/proftpd \
--pidfile /run/proftpd/proftpd.pid
eend $?
}
stop() {
[ "${RC_CMD}" != "restart" ] || check_configuration || return 1
ebegin "Stopping ProFTPD"
start-stop-daemon --stop --quiet --retry 20 \
--pidfile /run/proftpd/proftpd.pid
eend $?
}
reload() {
check_configuration || return 1
ebegin "Reloading ProFTPD"
start-stop-daemon --quiet --signal HUP \
--pidfile /run/proftpd/proftpd.pid
eend $?
}
As root, create a file named "proftpd" and put the above in there. Then after that, simply run.
# rc-update add proftpd default
That should enable it on boot.