File: /usr/iports/etc/rc.vsd
#!/bin/sh
### helpers
#just check for YES in uppercase and nothing else....
processLine(){
line="$@" # get all args
case $line in
*=*)
set -- `echo $line | tr '=' ' '`
key=$1
value=$2
case $key in
postgresql_enable)
if [ $value == "\"YES\"" ]; then
postgresql_enable="YES"
fi
;;
apache24_enable)
if [ $value == "\"YES\"" ]; then
apache24_enable="YES"
fi
;;
apacheroot)
if [ $value == "\"NO\"" ]; then
apacheroot="NO"
fi
;;
mysql_enable)
if [ $value == "\"YES\"" ]; then
mysql_enable="YES"
fi
;;
mysql57_enable)
if [ $value == "\"YES\"" ]; then
mysql57_enable="YES"
fi
;;
maria_enable)
if [ $value == "\"YES\"" ]; then
maria_enable="YES"
fi
;;
mongod_enable)
if [ $value == "\"YES\"" ]; then
mongod_enable="YES"
fi
;;
dovecot_enable)
if [ $value == "\"YES\"" ]; then
dovecot_enable="YES"
fi
;;
proftpd_enable)
if [ $value == "\"YES\"" ]; then
proftpd_enable="YES"
fi
;;
esac
;;
esac
}
processConfig(){
CONFIG="/etc/rc.conf"
x=0
while [ $x -lt $(wc -l <$CONFIG) ]
do
let x=x+1 1>/dev/null 2>/dev/null
LINE=`head -n $x $CONFIG | tail -n 1`
processLine $LINE
done
}
######### script
#raise the VSes securelevel....
#sysctl kern.securelevel=1
. /etc/rc.subr
#needed for every app who wants to use saslauthd - currently sendmail only
SASL_CONF_PATH=/usr/iports/lib/sasl2
export SASL_CONF_PATH
# Look for our init script
for ezjail_flavour in /ezjail.flavour.*; do
[ -x "${ezjail_flavour}" ] && "${ezjail_flavour}"
done
#setting user variables
postgresql_enable="NO"
apache24_enable="NO"
mysql_enable="NO"
mysql57_enable="NO"
maria_enable="NO"
mongod_enable="NO"
dovecot_enable="NO"
proftpd_enable="NO"
# to be root, or not to be
# be SURE to change /var/log, /var/run pathes in httpd.conf and rc.d scripts
# if you change this!
# we will NOT change this until we remove root rights at all from the DMR skel
apacheroot="YES"
#Read the config file WITHOUT executing anything....
processConfig
HOME=/
PATH=/usr/local/sbin:/usr/local/bin:/usr/iports/bin:/usr/iports/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games
export HOME PATH
_boot="start"
##stopping?
while getopts "s" options; do
case $options in
s ) _boot="stop";;
esac
done
# force some flags...
network_interfaces=""
syslogd_flags="-ss"
cron_flags="-J 15"
postgresql_class="postgres"
sendmail_submit_enable="YES"
sendmail_outbound_enable="YES"
sendmail_msp_queue_enable="YES"
#core services
files="newsyslog syslogd ldconfig cleartmp motd sshd saslauthd sendmail cron"
for _rc_elem in ${files}; do
run_rc_script /etc/rc.d/${_rc_elem} ${_boot}
done
###KEEP AN I ON THE FUCKING WHITESPACES!!
if [ "$postgresql_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/postgresql" ${_boot}
fi
if [ "$proftpd_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/proftpd" ${_boot}
fi
if [ "$mysql_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/mysql-server" ${_boot}
elif [ "$maria_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/maria-server" ${_boot}
elif [ "$mysql57_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/mysql57-server" ${_boot}
fi
if [ "$mongod_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/mongod" ${_boot}
fi
if [ "$dovecot_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
run_rc_script "/etc/rc.d/dovecot" ${_boot}
fi
if [ "$apache24_enable" == "YES" ] || [ "$_boot" == "stop" ]; then
case "$apacheroot" in
YES)
run_rc_script "/etc/rc.d/apache24" ${_boot}
;;
NO)
su -m web -c "/etc/rc.d/apache24 ${_boot}"
;;
esac
fi
echo ''
date
# local services by root
if [ -f /etc/rc ]; then
load_rc_config 'XXX'
# If we receive a SIGALRM, re-source /etc/rc.conf; this allows rc.d
# scripts to perform "boot-time configuration" including enabling and
# disabling rc.d scripts which appear later in the boot order.
trap "_rc_conf_loaded=false; load_rc_config 'XXX'" ALRM
files=`rcorder /usr/local/etc/rc.d/* 2>/dev/null`
for _rc_elem in ${files}; do
run_rc_script ${_rc_elem} ${_boot}
done
fi
# local services by root
if [ -f /etc/rc.local ]; then
. /etc/rc.local &
fi
# Virtual server startup
if [ -f /etc/rc.admin ]; then
su -m admin -c "/bin/sh /etc/rc.admin &"
fi
exit 0