Init scripts: use uppercase for constants

This commit is contained in:
Calin Crisan 2019-01-12 00:02:05 +02:00
parent 58a6be0e49
commit 39e10d0eff
19 changed files with 181 additions and 167 deletions

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
sys_modules_file="/etc/modules" SYS_MODULES_FILE="/etc/modules"
boot_modules_file="/boot/modules" BOOT_MODULES_FILE="/boot/modules"
modules_file="/data/etc/modules" MODULES_FILE="/data/etc/modules"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
@ -11,16 +11,16 @@ case "$1" in
start) start)
msg_begin "Loading kernel modules" msg_begin "Loading kernel modules"
if [[ -r $sys_modules_file ]]; then if [[ -r $SYS_MODULES_FILE ]]; then
cat $sys_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done cat $SYS_MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
fi fi
if [[ -r $boot_modules_file ]]; then if [[ -r $BOOT_MODULES_FILE ]]; then
cat $boot_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done cat $BOOT_MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
fi fi
if [[ -r $modules_file ]]; then if [[ -r $MODULES_FILE ]]; then
cat $modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done cat $MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
fi fi
msg_done msg_done

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
sys_hostname_file="/etc/hostname" SYS_HOSTNAME_FILE="/etc/hostname"
boot_hostname_file="/boot/hostname" BOOT_HOSTNAME_FILE="/boot/hostname"
hostname_file="/data/etc/hostname" HOSTNAME_FILE="/data/etc/hostname"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
@ -11,10 +11,10 @@ case "$1" in
start) start)
msg_begin "Setting hostname" msg_begin "Setting hostname"
prepare_conf $hostname_file $sys_hostname_file $boot_hostname_file prepare_conf $HOSTNAME_FILE $SYS_HOSTNAME_FILE $BOOT_HOSTNAME_FILE
if [[ -f $hostname_file ]]; then if [[ -f $HOSTNAME_FILE ]]; then
hostname=$(cat $hostname_file) hostname=$(cat $HOSTNAME_FILE)
else else
hostname="$os_prefix-$board_sn" hostname="$os_prefix-$board_sn"
fi fi

View File

@ -2,15 +2,16 @@
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
dmesg_log="/var/log/dmesg.log" DMESG_LOG="/var/log/dmesg.log"
case "$1" in case "$1" in
start) start)
msg_begin "Starting syslogd" msg_begin "Starting syslogd"
syslogd syslogd
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
echo "---- booting $os_name $os_version ----" >> $dmesg_log echo "---- booting $os_name $os_version ----" >> $DMESG_LOG
dmesg -T -w >> $dmesg_log & dmesg -T -w >> $DMESG_LOG &
;; ;;
stop) stop)

View File

@ -1,10 +1,13 @@
#!/bin/bash #!/bin/bash
test -f /etc/udev/udev.conf || exit 0 CONF=/etc/udev/udev.conf
test -f $CONF || exit 0
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
source /etc/udev/udev.conf source $CONF
start() { start() {
msg_begin "Starting eudev" msg_begin "Starting eudev"

View File

@ -1,17 +1,18 @@
#!/bin/bash #!/bin/bash
SYS_VERSION_FILE="/etc/version"
VERSION_FILE="/data/etc/version"
POST_UPGRADE_DIR="/usr/share/post-upgrade"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
sys_version_file="/etc/version" hash=$(md5sum $VERSION_FILE 2>/dev/null | cut -d ' ' -f 1)
version_file="/data/etc/version" sys_hash=$(md5sum $SYS_VERSION_FILE 2>/dev/null | cut -d ' ' -f 1)
post_upgrade_dir="/usr/share/post-upgrade"
hash=$(md5sum $version_file 2>/dev/null | cut -d ' ' -f 1)
sys_hash=$(md5sum $sys_version_file 2>/dev/null | cut -d ' ' -f 1)
test "$hash" == "$sys_hash" && exit 0 test "$hash" == "$sys_hash" && exit 0
test -d $post_upgrade_dir || exit 0 test -d $POST_UPGRADE_DIR || exit 0
function version_gt() { function version_gt() {
if [[ "$1" != "$2" ]] && [[ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]]; then if [[ "$1" != "$2" ]] && [[ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]]; then
@ -22,14 +23,14 @@ function version_gt() {
} }
function run_post_upgrade() { function run_post_upgrade() {
version="$(source $version_file 2>/dev/null && echo $os_version)" version="$(source $VERSION_FILE 2>/dev/null && echo $os_version)"
sys_version="$(source $sys_version_file 2>/dev/null && echo $os_version)" sys_version="$(source $SYS_VERSION_FILE 2>/dev/null && echo $os_version)"
versions=$(ls -1 $post_upgrade_dir | cut -d '.' -f 1) versions=$(ls -1 $POST_UPGRADE_DIR | cut -d '.' -f 1)
for v in $versions; do for v in $versions; do
if [[ -z "$version" ]] || version_gt $v $version; then if [[ -z "$version" ]] || version_gt $v $version; then
msg_begin "Post-upgrading to version $v" msg_begin "Post-upgrading to version $v"
out=$($post_upgrade_dir/$v.sh 2>&1) out=$($POST_UPGRADE_DIR/$v.sh 2>&1)
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
echo "$out" | logger -t post-upgrade echo "$out" | logger -t post-upgrade
fi fi
@ -39,7 +40,7 @@ function run_post_upgrade() {
case "$1" in case "$1" in
start) start)
run_post_upgrade run_post_upgrade
cp $sys_version_file $version_file cp $SYS_VERSION_FILE $VERSION_FILE
;; ;;
stop) stop)

View File

@ -1,11 +1,12 @@
#!/bin/bash #!/bin/bash
sys_btconf="/etc/bluetooth.conf" SYS_BTCONF="/etc/bluetooth.conf"
boot_btconf="/boot/bluetooth.conf" BOOT_BTCONF="/boot/bluetooth.conf"
btconf="/data/etc/bluetooth.conf" BTCONF="/data/etc/bluetooth.conf"
# dbus is currently only used by bluez # dbus is currently only used by bluez
test -f $btconf || test -f $boot_btconf || test -f $sys_btconf || exit 0 test -f $BTCONF || test -f $BOOT_BTCONF || test -f $SYS_BTCONF || exit 0
test -x /usr/bin/dbus-daemon || exit 0 test -x /usr/bin/dbus-daemon || exit 0

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/hostapd.conf" SYS_CONF="/etc/hostapd.conf"
boot_conf="/boot/hostapd.conf" BOOT_CONF="/boot/hostapd.conf"
conf="/data/etc/hostapd.conf" CONF="/data/etc/hostapd.conf"
log="/var/log/hostapd.log" LOG="/var/log/hostapd.log"
prog="/usr/sbin/hostapd" PROG="/usr/sbin/hostapd"
watch_conf="/data/etc/watch.conf" WATCH_CONF="/data/etc/watch.conf"
link_watch=yes link_watch=yes
link_watch_timeout=20 link_watch_timeout=20
@ -15,10 +15,10 @@ link_watch_timeout=20
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
test -f $watch_conf && source $watch_conf test -f $WATCH_CONF && source $WATCH_CONF
running() { running() {
@ -50,11 +50,11 @@ start() {
fi fi
done done
iface=$(cat $conf | grep interface | cut -d '=' -f 2) iface=$(cat $CONF | grep interface | cut -d '=' -f 2)
module=$(basename $(readlink /sys/class/net/$iface/device/driver/module 2>/dev/null) 2>/dev/null) module=$(basename $(readlink /sys/class/net/$iface/device/driver/module 2>/dev/null) 2>/dev/null)
iwconfig $iface power off &> /dev/null iwconfig $iface power off &> /dev/null
$prog $conf &> $log & $PROG $CONF &> $LOG &
if [[ "$link_watch" == "yes" ]]; then if [[ "$link_watch" == "yes" ]]; then
watch & watch &

View File

@ -1,27 +1,27 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/wpa_supplicant.conf" SYS_CONF="/etc/wpa_supplicant.conf"
boot_conf="/boot/wpa_supplicant.conf" BOOT_CONF="/boot/wpa_supplicant.conf"
conf="/data/etc/wpa_supplicant.conf" CONF="/data/etc/wpa_supplicant.conf"
log="/var/log/wpa_supplicant.log" LOG="/var/log/wpa_supplicant.log"
prog="/usr/sbin/wpa_supplicant" PROG="/usr/sbin/wpa_supplicant"
driver=nl80211,wext DRIVER=nl80211,wext
sys_watch_conf="/etc/watch.conf" SYS_WATCH_CONF="/etc/watch.conf"
boot_watch_conf="/boot/watch.conf" BOOT_WATCH_CONF="/boot/watch.conf"
watch_conf="/data/etc/watch.conf" WATCH_CONF="/data/etc/watch.conf"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $watch_conf $sys_watch_conf $boot_watch_conf prepare_conf $WATCH_CONF $SYS_WATCH_CONF $BOOT_WATCH_CONF
source $watch_conf source $WATCH_CONF
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
ssid=$(cat $conf | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) ssid=$(cat $CONF | grep ssid | grep -v scan_ssid | cut -d '"' -f 2)
test -n "$ssid" || exit 0 test -n "$ssid" || exit 0
@ -70,7 +70,7 @@ start() {
iwconfig $os_wlan power off &> /dev/null iwconfig $os_wlan power off &> /dev/null
iw $os_wlan set power_save off &> /dev/null iw $os_wlan set power_save off &> /dev/null
$prog -i$os_wlan -c$conf -D$driver -B &> $log $PROG -i$os_wlan -c$CONF -D$DRIVER -B &> $LOG
count=0 count=0
while true; do while true; do
sleep 1 sleep 1

View File

@ -1,23 +1,23 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/ppp/default" SYS_CONF="/etc/ppp/default"
boot_conf="/boot/ppp" BOOT_CONF="/boot/ppp"
conf="/data/etc/ppp" CONF="/data/etc/ppp"
prog="/usr/sbin/pppd" PROG="/usr/sbin/pppd"
provider="mobile" PROVIDER="mobile"
watch_conf="/data/etc/watch.conf" WATCH_CONF="/data/etc/watch.conf"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -e $conf/modem || exit 0 test -e $CONF/modem || exit 0
test -e $conf/apn || exit 0 test -e $CONF/apn || exit 0
source $watch_conf source $WATCH_CONF
test "$os_networkless" == "true" && exit 0 test "$os_networkless" == "true" && exit 0
@ -51,15 +51,15 @@ udev_trigger_add() {
} }
start() { start() {
test -e $conf/auth || touch $conf/auth test -e $CONF/auth || touch $CONF/auth
test -e $conf/extra || touch $conf/extra test -e $CONF/extra || touch $CONF/extra
test -e $conf/pin || touch $conf/pin test -e $CONF/pin || touch $CONF/pin
mknod /dev/ppp c 108 0 &>/dev/null mknod /dev/ppp c 108 0 &>/dev/null
msg_begin "Starting pppd" msg_begin "Starting pppd"
# wait for modem # wait for modem
modem=$(head -n 1 $conf/modem) modem=$(head -n 1 $CONF/modem)
if ! [[ -e /dev/$modem ]]; then if ! [[ -e /dev/$modem ]]; then
udev_trigger_add 4 & udev_trigger_add 4 &
fi fi
@ -79,7 +79,7 @@ start() {
return return
fi fi
$prog call $provider $PROG call $PROVIDER
count=0 count=0
while true; do while true; do
sleep 1 sleep 1

View File

@ -1,13 +1,14 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/bluetooth.conf" SYS_CONF="/etc/bluetooth.conf"
boot_conf="/boot/bluetooth.conf" BOOT_CONF="/boot/bluetooth.conf"
conf="/data/etc/bluetooth.conf" CONF="/data/etc/bluetooth.conf"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
hci=hci0 hci=hci0
bluetoothd=/usr/libexec/bluetooth/bluetoothd bluetoothd=/usr/libexec/bluetooth/bluetoothd
@ -21,7 +22,7 @@ test -x $bluetoothd || exit 0
configure() { configure() {
mkdir -p $run_data_dir mkdir -p $run_data_dir
ln -sf $run_data_dir $data_dir ln -sf $run_data_dir $data_dir
cp $conf $run_conf cp $CONF $run_conf
# if no specific name configured, use hostname # if no specific name configured, use hostname
if ! grep -E 'Name\s*=' $run_conf &>/dev/null; then if ! grep -E 'Name\s*=' $run_conf &>/dev/null; then

View File

@ -1,21 +1,22 @@
#!/bin/bash #!/bin/bash
mkdir -p /var/lib/dhcp DH_CONF="/var/cache/dhclient.conf"
dh_conf="/var/cache/dhclient.conf" SYS_STATIC_CONF="/etc/static_ip.conf"
sys_static_conf="/etc/static_ip.conf" BOOT_STATIC_CONF="/boot/static_ip.conf"
boot_static_conf="/boot/static_ip.conf" STATIC_CONF="/data/etc/static_ip.conf"
static_conf="/data/etc/static_ip.conf" WATCH_CONF="/data/etc/watch.conf"
watch_conf="/data/etc/watch.conf"
link_nego_timeout=10 LINK_NEGO_TIMEOUT=10
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
source $watch_conf source $WATCH_CONF
prepare_conf $static_conf $sys_static_conf $boot_static_conf prepare_conf $STATIC_CONF $SYS_STATIC_CONF $BOOT_STATIC_CONF
test -r $static_conf && source $static_conf test -r $STATIC_CONF && source $STATIC_CONF
mkdir -p /var/lib/dhcp
watch_eth() { watch_eth() {
@ -81,7 +82,7 @@ start_wlan() {
static_ip="" # won't be used again static_ip="" # won't be used again
else else
msg_done dhcp msg_done dhcp
dhclient -cf "$dh_conf" $os_wlan dhclient -cf "$DH_CONF" $os_wlan
fi fi
if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_wlan | grep inet &>/dev/null; then if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_wlan | grep inet &>/dev/null; then
@ -120,12 +121,12 @@ start_eth() {
done done
# wait for link # wait for link
test "$link_watch" == "true" || link_nego_timeout=5 test "$link_watch" == "true" || LINK_NEGO_TIMEOUT=5
count=0 count=0
while [[ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]]; do while [[ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]]; do
sleep 1 sleep 1
count=$(($count + 1)) count=$(($count + 1))
if [[ $count -ge $link_nego_timeout ]]; then if [[ $count -ge $LINK_NEGO_TIMEOUT ]]; then
msg_done "no link" msg_done "no link"
return 1 return 1
fi fi
@ -141,7 +142,7 @@ start_eth() {
static_ip="" # won't be used again static_ip="" # won't be used again
else else
msg_done dhcp msg_done dhcp
dhclient -cf "$dh_conf" $os_eth dhclient -cf "$DH_CONF" $os_eth
fi fi
if [[ "$link_watch" == "true" ]]; then if [[ "$link_watch" == "true" ]]; then

View File

@ -1,13 +1,14 @@
#!/bin/bash #!/bin/bash
watch_conf="/data/etc/watch.conf" WATCH_CONF="/data/etc/watch.conf"
netwatch_retries=3 NETWATCH_RETRIES=3
netwatch_timeout=5 NETWATCH_TIMEOUT=5
netwatch_interval=20 NETWATCH_INTERVAL=20
test -f $watch_conf && source $watch_conf || exit 0
if [[ -z "$netwatch_host" ]] || [[ -z "$netwatch_port" ]]; then test -f $WATCH_CONF && source $WATCH_CONF || exit 0
if [[ -z "$netwatch_host" || -z "$netwatch_port" ]]; then
exit 0 exit 0
fi fi
@ -15,15 +16,16 @@ test -n "$os_version" || source /etc/init.d/base
test "$os_networkless" == "true" && exit 0 test "$os_networkless" == "true" && exit 0
watch() { watch() {
count=0 count=0
netwatch_retries=$(($netwatch_retries - 1)) NETWATCH_RETRIES=$(($NETWATCH_RETRIES - 1))
while true; do while true; do
sleep $netwatch_interval sleep $NETWATCH_INTERVAL
if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then if nc -z -w $NETWATCH_TIMEOUT $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then
count=0 count=0
else else
if [[ $count -lt $netwatch_retries ]]; then if [[ $count -lt $NETWATCH_RETRIES ]]; then
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port" logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port"
count=$(($count + 1)) count=$(($count + 1))
continue continue

View File

@ -1,18 +1,19 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/firewall.sh" SYS_CONF="/etc/firewall.sh"
boot_conf="/boot/firewall.sh" BOOT_CONF="/boot/firewall.sh"
conf="/data/etc/firewall.sh" CONF="/data/etc/firewall.sh"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
start() { start() {
msg_begin "Starting firewall" msg_begin "Starting firewall"
bash $conf bash $CONF
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
} }

View File

@ -1,28 +1,28 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/dnsmasq.conf" SYS_CONF="/etc/dnsmasq.conf"
boot_conf="/boot/dnsmasq.conf" BOOT_CONF="/boot/dnsmasq.conf"
conf="/data/etc/dnsmasq.conf" CONF="/data/etc/dnsmasq.conf"
log="/var/log/dnsmasq.log" LOG="/var/log/dnsmasq.log"
prog="/usr/sbin/dnsmasq" PROG="/usr/sbin/dnsmasq"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
start() { start() {
msg_begin "Starting dnsmasq" msg_begin "Starting dnsmasq"
iface=$(cat $conf | grep interface | cut -d '=' -f 2) iface=$(cat $CONF | grep interface | cut -d '=' -f 2)
ip=$(cat $conf | grep range | cut -d '=' -f 2 | cut -d '.' -f 1,2,3).1 ip=$(cat $CONF | grep range | cut -d '=' -f 2 | cut -d '.' -f 1,2,3).1
ifconfig $iface $ip ifconfig $iface $ip
$prog -C $conf --log-facility=$log $PROG -C $CONF --log-facility=$LOG
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
} }

View File

@ -1,23 +1,23 @@
#!/bin/bash #!/bin/bash
# Date executable points to /bin/busybox\ date explicitly in the cases that date binary gets overwritten # Date executable points to /bin/busybox\ date explicitly in the cases that date binary gets overwritten
date_exec=/bin/busybox\ date DATE_PROG=/bin/busybox\ date
sys_conf="/etc/date.conf" SYS_CONF="/etc/date.conf"
boot_conf="/boot/date.conf" BOOT_CONF="/boot/date.conf"
conf="/data/etc/date.conf" CONF="/data/etc/date.conf"
sys_ntp_conf="/etc/ntp.conf" SYS_NTP_CONF="/etc/ntp.conf"
boot_ntp_conf="/boot/ntp.conf" BOOT_NTP_CONF="/boot/ntp.conf"
ntp_conf="/data/etc/ntp.conf" NTP_CONF="/data/etc/ntp.conf"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
prepare_conf $conf $sys_conf $boot_conf prepare_conf $CONF $SYS_CONF $BOOT_CONF
prepare_conf $ntp_conf $sys_ntp_conf $boot_ntp_conf prepare_conf $NTP_CONF $SYS_NTP_CONF $BOOT_NTP_CONF
test -f $conf || exit 0 test -f $CONF || exit 0
test "$os_networkless" == "true" && exit 0 test "$os_networkless" == "true" && exit 0
@ -26,23 +26,24 @@ date_method=http
date_host="google.com" date_host="google.com"
date_interval="900" date_interval="900"
source $conf source $CONF
set_current_date_http() { set_current_date_http() {
date_str=$(curl -v -s -m $date_timeout -X GET http://$date_host 2>&1 | grep Date | sed -e 's/< Date: //') date_str=$(curl -v -s -m $date_timeout -X GET http://$date_host 2>&1 | grep Date | sed -e 's/< Date: //')
test -z "$date_str" && return 1 test -z "$date_str" && return 1
$date_exec -u -D "%a, %d %b %Y %H:%M:%S" -s "$date_str" > /dev/null $DATE_PROG -u -D "%a, %d %b %Y %H:%M:%S" -s "$date_str" > /dev/null
return $? return $?
} }
set_current_date_ntp() { set_current_date_ntp() {
cat $ntp_conf | grep server | head -n 1 | cut -d ' ' -f 2 | xargs ntpdate -t $date_timeout -s cat $NTP_CONF | grep server | head -n 1 | cut -d ' ' -f 2 | xargs ntpdate -t $date_timeout -s
} }
start_http() { start_http() {
msg_begin "Setting current date using http" msg_begin "Setting current date using http"
set_current_date_http || set_current_date_http set_current_date_http || set_current_date_http
test $? == 0 && msg_done "$($date_exec)" || msg_fail test $? == 0 && msg_done "$($DATE_PROG)" || msg_fail
msg_begin "Starting http date updater" msg_begin "Starting http date updater"
while true; do while true; do
@ -55,23 +56,23 @@ start_http() {
start_ntp() { start_ntp() {
mkdir -p /var/lib/ntp mkdir -p /var/lib/ntp
cat $ntp_conf | grep -v iburst > ${ntp_conf}.tmp cat $NTP_CONF | grep -v iburst > ${NTP_CONF}.tmp
if [[ -n "$date_ntp_server" ]]; then if [[ -n "$date_ntp_server" ]]; then
echo "server $date_ntp_server iburst" > $ntp_conf echo "server $date_ntp_server iburst" > $NTP_CONF
else else
cat $sys_ntp_conf | grep iburst > $ntp_conf cat $SYS_NTP_CONF | grep iburst > $NTP_CONF
fi fi
cat ${ntp_conf}.tmp >> $ntp_conf cat ${NTP_CONF}.tmp >> $NTP_CONF
rm ${ntp_conf}.tmp rm ${NTP_CONF}.tmp
msg_begin "Setting current date using ntp" msg_begin "Setting current date using ntp"
set_current_date_ntp || set_current_date_ntp set_current_date_ntp || set_current_date_ntp
test $? == 0 && msg_done "$($date_exec)" || msg_fail test $? == 0 && msg_done "$($DATE_PROG)" || msg_fail
msg_begin "Starting ntpd" msg_begin "Starting ntpd"
ntpd -g -c $ntp_conf ntpd -g -c $NTP_CONF
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
} }
@ -94,7 +95,7 @@ start() {
start_ntp start_ntp
fi fi
echo "system date is $($date_exec '+%Y-%m-%d %H:%M:%S')" > /dev/kmsg echo "system date is $($DATE_PROG '+%Y-%m-%d %H:%M:%S')" > /dev/kmsg
} }
stop() { stop() {

View File

@ -1,19 +1,19 @@
#!/bin/bash #!/bin/bash
sys_conf="/etc/crontabs" SYS_CONF="/etc/crontabs"
conf="/data/etc/crontabs" CONF="/data/etc/crontabs"
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
start() { start() {
msg_begin "Starting crond" msg_begin "Starting crond"
if [[ -d $sys_conf ]]; then if [[ -d $SYS_CONF ]]; then
/usr/sbin/crond -c $sys_conf /usr/sbin/crond -c $SYS_CONF
fi fi
mkdir -p $conf mkdir -p $CONF
/usr/sbin/crond -c $conf /usr/sbin/crond -c $CONF
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
} }

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
conf="/etc/sshd_config" CONF="/etc/sshd_config"
test -f $conf || exit 0 test -f $CONF || exit 0
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
@ -22,7 +22,7 @@ start() {
echo "Welcome to $hostname!" > /var/cache/sshd_banner echo "Welcome to $hostname!" > /var/cache/sshd_banner
sync sync
/usr/sbin/sshd -f $conf /usr/sbin/sshd -f $CONF
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
} }

View File

@ -1,15 +1,16 @@
#!/bin/bash #!/bin/bash
userinit_sh="/data/etc/userinit.sh" USERINIT="/data/etc/userinit.sh"
test -f $userinit_sh || exit 0
test -f $USERINIT || exit 0
test -n "$os_version" || source /etc/init.d/base test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Executing user init script" msg_begin "Executing user init script"
/bin/bash $userinit_sh /bin/bash $USERINIT
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
;; ;;

View File

@ -1,20 +1,21 @@
_sys_conf="/etc/os.conf" sys_conf="/etc/os.conf"
_boot_conf="/boot/os.conf" boot_conf="/boot/os.conf"
_data_conf="/data/etc/os.conf" data_conf="/data/etc/os.conf"
# source in all conf files in order of precedence # source in all conf files in order of precedence
if [[ -f $_sys_conf ]]; then if [[ -f $sys_conf ]]; then
source $_sys_conf source $sys_conf
fi fi
if [[ -f $_data_conf ]]; then if [[ -f $data_conf ]]; then
source $_data_conf source $data_conf
fi fi
if [[ -f $_boot_conf ]]; then if [[ -f $boot_conf ]]; then
source $_boot_conf source $boot_conf
fi fi
unset _sys_conf _boot_conf _data_conf unset sys_conf boot_conf data_conf