From 39e10d0eff71c7543d95022c7079f36eabac7695 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 12 Jan 2019 00:02:05 +0200 Subject: [PATCH] Init scripts: use uppercase for constants --- board/common/overlay/etc/init.d/S02modules | 18 ++++---- board/common/overlay/etc/init.d/S03hostname | 12 ++--- board/common/overlay/etc/init.d/S04syslog | 7 +-- board/common/overlay/etc/init.d/S12udev | 7 ++- .../common/overlay/etc/init.d/S14postupgrade | 25 ++++++----- board/common/overlay/etc/init.d/S30dbus | 9 ++-- board/common/overlay/etc/init.d/S33hostapd | 22 ++++----- board/common/overlay/etc/init.d/S35wifi | 30 ++++++------- board/common/overlay/etc/init.d/S36ppp | 30 ++++++------- board/common/overlay/etc/init.d/S37bluetooth | 13 +++--- board/common/overlay/etc/init.d/S40network | 29 ++++++------ board/common/overlay/etc/init.d/S41netwatch | 22 ++++----- board/common/overlay/etc/init.d/S43firewall | 13 +++--- board/common/overlay/etc/init.d/S45dnsmasq | 20 ++++----- board/common/overlay/etc/init.d/S50date | 45 ++++++++++--------- board/common/overlay/etc/init.d/S51crond | 12 ++--- board/common/overlay/etc/init.d/S60sshd | 6 +-- board/common/overlay/etc/init.d/S98userinit | 7 +-- board/common/overlay/etc/init.d/os_conf | 21 ++++----- 19 files changed, 181 insertions(+), 167 deletions(-) diff --git a/board/common/overlay/etc/init.d/S02modules b/board/common/overlay/etc/init.d/S02modules index 26b91921df..b667086346 100755 --- a/board/common/overlay/etc/init.d/S02modules +++ b/board/common/overlay/etc/init.d/S02modules @@ -1,8 +1,8 @@ #!/bin/bash -sys_modules_file="/etc/modules" -boot_modules_file="/boot/modules" -modules_file="/data/etc/modules" +SYS_MODULES_FILE="/etc/modules" +BOOT_MODULES_FILE="/boot/modules" +MODULES_FILE="/data/etc/modules" test -n "$os_version" || source /etc/init.d/base @@ -11,16 +11,16 @@ case "$1" in start) msg_begin "Loading kernel modules" - if [[ -r $sys_modules_file ]]; then - cat $sys_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done + if [[ -r $SYS_MODULES_FILE ]]; then + cat $SYS_MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done fi - if [[ -r $boot_modules_file ]]; then - cat $boot_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done + if [[ -r $BOOT_MODULES_FILE ]]; then + cat $BOOT_MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done fi - if [[ -r $modules_file ]]; then - cat $modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done + if [[ -r $MODULES_FILE ]]; then + cat $MODULES_FILE | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done fi msg_done diff --git a/board/common/overlay/etc/init.d/S03hostname b/board/common/overlay/etc/init.d/S03hostname index 9feb017d92..f081363b86 100755 --- a/board/common/overlay/etc/init.d/S03hostname +++ b/board/common/overlay/etc/init.d/S03hostname @@ -1,8 +1,8 @@ #!/bin/bash -sys_hostname_file="/etc/hostname" -boot_hostname_file="/boot/hostname" -hostname_file="/data/etc/hostname" +SYS_HOSTNAME_FILE="/etc/hostname" +BOOT_HOSTNAME_FILE="/boot/hostname" +HOSTNAME_FILE="/data/etc/hostname" test -n "$os_version" || source /etc/init.d/base @@ -11,10 +11,10 @@ case "$1" in start) 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 - hostname=$(cat $hostname_file) + if [[ -f $HOSTNAME_FILE ]]; then + hostname=$(cat $HOSTNAME_FILE) else hostname="$os_prefix-$board_sn" fi diff --git a/board/common/overlay/etc/init.d/S04syslog b/board/common/overlay/etc/init.d/S04syslog index b7a1eb3ac4..da74427391 100755 --- a/board/common/overlay/etc/init.d/S04syslog +++ b/board/common/overlay/etc/init.d/S04syslog @@ -2,15 +2,16 @@ test -n "$os_version" || source /etc/init.d/base -dmesg_log="/var/log/dmesg.log" +DMESG_LOG="/var/log/dmesg.log" + case "$1" in start) msg_begin "Starting syslogd" syslogd test $? == 0 && msg_done || msg_fail - echo "---- booting $os_name $os_version ----" >> $dmesg_log - dmesg -T -w >> $dmesg_log & + echo "---- booting $os_name $os_version ----" >> $DMESG_LOG + dmesg -T -w >> $DMESG_LOG & ;; stop) diff --git a/board/common/overlay/etc/init.d/S12udev b/board/common/overlay/etc/init.d/S12udev index ce1c2af7f8..2c2f20c4b1 100755 --- a/board/common/overlay/etc/init.d/S12udev +++ b/board/common/overlay/etc/init.d/S12udev @@ -1,10 +1,13 @@ #!/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 -source /etc/udev/udev.conf +source $CONF start() { msg_begin "Starting eudev" diff --git a/board/common/overlay/etc/init.d/S14postupgrade b/board/common/overlay/etc/init.d/S14postupgrade index bb41a4e105..225c0f6c6e 100755 --- a/board/common/overlay/etc/init.d/S14postupgrade +++ b/board/common/overlay/etc/init.d/S14postupgrade @@ -1,17 +1,18 @@ #!/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 -sys_version_file="/etc/version" -version_file="/data/etc/version" -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) +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 -d $post_upgrade_dir || exit 0 +test -d $POST_UPGRADE_DIR || exit 0 function version_gt() { 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() { - version="$(source $version_file 2>/dev/null && echo $os_version)" - sys_version="$(source $sys_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)" - 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 if [[ -z "$version" ]] || version_gt $v $version; then 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 echo "$out" | logger -t post-upgrade fi @@ -39,7 +40,7 @@ function run_post_upgrade() { case "$1" in start) run_post_upgrade - cp $sys_version_file $version_file + cp $SYS_VERSION_FILE $VERSION_FILE ;; stop) diff --git a/board/common/overlay/etc/init.d/S30dbus b/board/common/overlay/etc/init.d/S30dbus index 946aa5271d..92fad2e731 100755 --- a/board/common/overlay/etc/init.d/S30dbus +++ b/board/common/overlay/etc/init.d/S30dbus @@ -1,11 +1,12 @@ #!/bin/bash -sys_btconf="/etc/bluetooth.conf" -boot_btconf="/boot/bluetooth.conf" -btconf="/data/etc/bluetooth.conf" +SYS_BTCONF="/etc/bluetooth.conf" +BOOT_BTCONF="/boot/bluetooth.conf" +BTCONF="/data/etc/bluetooth.conf" + # 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 diff --git a/board/common/overlay/etc/init.d/S33hostapd b/board/common/overlay/etc/init.d/S33hostapd index 6d1ace6df5..d55dc040ae 100755 --- a/board/common/overlay/etc/init.d/S33hostapd +++ b/board/common/overlay/etc/init.d/S33hostapd @@ -1,13 +1,13 @@ #!/bin/bash -sys_conf="/etc/hostapd.conf" -boot_conf="/boot/hostapd.conf" -conf="/data/etc/hostapd.conf" +SYS_CONF="/etc/hostapd.conf" +BOOT_CONF="/boot/hostapd.conf" +CONF="/data/etc/hostapd.conf" -log="/var/log/hostapd.log" -prog="/usr/sbin/hostapd" +LOG="/var/log/hostapd.log" +PROG="/usr/sbin/hostapd" -watch_conf="/data/etc/watch.conf" +WATCH_CONF="/data/etc/watch.conf" link_watch=yes link_watch_timeout=20 @@ -15,10 +15,10 @@ link_watch_timeout=20 test -n "$os_version" || source /etc/init.d/base -prepare_conf $conf $sys_conf $boot_conf -test -f $conf || exit 0 +prepare_conf $CONF $SYS_CONF $BOOT_CONF +test -f $CONF || exit 0 -test -f $watch_conf && source $watch_conf +test -f $WATCH_CONF && source $WATCH_CONF running() { @@ -50,11 +50,11 @@ start() { fi 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) iwconfig $iface power off &> /dev/null - $prog $conf &> $log & + $PROG $CONF &> $LOG & if [[ "$link_watch" == "yes" ]]; then watch & diff --git a/board/common/overlay/etc/init.d/S35wifi b/board/common/overlay/etc/init.d/S35wifi index 9b17d30ba7..c89466b6ac 100755 --- a/board/common/overlay/etc/init.d/S35wifi +++ b/board/common/overlay/etc/init.d/S35wifi @@ -1,27 +1,27 @@ #!/bin/bash -sys_conf="/etc/wpa_supplicant.conf" -boot_conf="/boot/wpa_supplicant.conf" -conf="/data/etc/wpa_supplicant.conf" +SYS_CONF="/etc/wpa_supplicant.conf" +BOOT_CONF="/boot/wpa_supplicant.conf" +CONF="/data/etc/wpa_supplicant.conf" -log="/var/log/wpa_supplicant.log" -prog="/usr/sbin/wpa_supplicant" -driver=nl80211,wext +LOG="/var/log/wpa_supplicant.log" +PROG="/usr/sbin/wpa_supplicant" +DRIVER=nl80211,wext -sys_watch_conf="/etc/watch.conf" -boot_watch_conf="/boot/watch.conf" -watch_conf="/data/etc/watch.conf" +SYS_WATCH_CONF="/etc/watch.conf" +BOOT_WATCH_CONF="/boot/watch.conf" +WATCH_CONF="/data/etc/watch.conf" test -n "$os_version" || source /etc/init.d/base -prepare_conf $watch_conf $sys_watch_conf $boot_watch_conf -source $watch_conf +prepare_conf $WATCH_CONF $SYS_WATCH_CONF $BOOT_WATCH_CONF +source $WATCH_CONF -prepare_conf $conf $sys_conf $boot_conf -test -f $conf || exit 0 +prepare_conf $CONF $SYS_CONF $BOOT_CONF +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 @@ -70,7 +70,7 @@ start() { iwconfig $os_wlan power 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 while true; do sleep 1 diff --git a/board/common/overlay/etc/init.d/S36ppp b/board/common/overlay/etc/init.d/S36ppp index 53972281c6..03e21ee5ba 100755 --- a/board/common/overlay/etc/init.d/S36ppp +++ b/board/common/overlay/etc/init.d/S36ppp @@ -1,23 +1,23 @@ #!/bin/bash -sys_conf="/etc/ppp/default" -boot_conf="/boot/ppp" -conf="/data/etc/ppp" +SYS_CONF="/etc/ppp/default" +BOOT_CONF="/boot/ppp" +CONF="/data/etc/ppp" -prog="/usr/sbin/pppd" -provider="mobile" +PROG="/usr/sbin/pppd" +PROVIDER="mobile" -watch_conf="/data/etc/watch.conf" +WATCH_CONF="/data/etc/watch.conf" 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/apn || exit 0 +test -e $CONF/modem || exit 0 +test -e $CONF/apn || exit 0 -source $watch_conf +source $WATCH_CONF test "$os_networkless" == "true" && exit 0 @@ -51,15 +51,15 @@ udev_trigger_add() { } start() { - test -e $conf/auth || touch $conf/auth - test -e $conf/extra || touch $conf/extra - test -e $conf/pin || touch $conf/pin + test -e $CONF/auth || touch $CONF/auth + test -e $CONF/extra || touch $CONF/extra + test -e $CONF/pin || touch $CONF/pin mknod /dev/ppp c 108 0 &>/dev/null msg_begin "Starting pppd" # wait for modem - modem=$(head -n 1 $conf/modem) + modem=$(head -n 1 $CONF/modem) if ! [[ -e /dev/$modem ]]; then udev_trigger_add 4 & fi @@ -79,7 +79,7 @@ start() { return fi - $prog call $provider + $PROG call $PROVIDER count=0 while true; do sleep 1 diff --git a/board/common/overlay/etc/init.d/S37bluetooth b/board/common/overlay/etc/init.d/S37bluetooth index 3acdd69d1f..13b61893be 100755 --- a/board/common/overlay/etc/init.d/S37bluetooth +++ b/board/common/overlay/etc/init.d/S37bluetooth @@ -1,13 +1,14 @@ #!/bin/bash -sys_conf="/etc/bluetooth.conf" -boot_conf="/boot/bluetooth.conf" -conf="/data/etc/bluetooth.conf" +SYS_CONF="/etc/bluetooth.conf" +BOOT_CONF="/boot/bluetooth.conf" +CONF="/data/etc/bluetooth.conf" + test -n "$os_version" || source /etc/init.d/base -prepare_conf $conf $sys_conf $boot_conf -test -f $conf || exit 0 +prepare_conf $CONF $SYS_CONF $BOOT_CONF +test -f $CONF || exit 0 hci=hci0 bluetoothd=/usr/libexec/bluetooth/bluetoothd @@ -21,7 +22,7 @@ test -x $bluetoothd || exit 0 configure() { mkdir -p $run_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 ! grep -E 'Name\s*=' $run_conf &>/dev/null; then diff --git a/board/common/overlay/etc/init.d/S40network b/board/common/overlay/etc/init.d/S40network index 7bd0ea7d0a..df8d2b932d 100755 --- a/board/common/overlay/etc/init.d/S40network +++ b/board/common/overlay/etc/init.d/S40network @@ -1,21 +1,22 @@ #!/bin/bash -mkdir -p /var/lib/dhcp -dh_conf="/var/cache/dhclient.conf" -sys_static_conf="/etc/static_ip.conf" -boot_static_conf="/boot/static_ip.conf" -static_conf="/data/etc/static_ip.conf" -watch_conf="/data/etc/watch.conf" +DH_CONF="/var/cache/dhclient.conf" +SYS_STATIC_CONF="/etc/static_ip.conf" +BOOT_STATIC_CONF="/boot/static_ip.conf" +STATIC_CONF="/data/etc/static_ip.conf" +WATCH_CONF="/data/etc/watch.conf" -link_nego_timeout=10 +LINK_NEGO_TIMEOUT=10 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 -test -r $static_conf && source $static_conf +prepare_conf $STATIC_CONF $SYS_STATIC_CONF $BOOT_STATIC_CONF +test -r $STATIC_CONF && source $STATIC_CONF + +mkdir -p /var/lib/dhcp watch_eth() { @@ -81,7 +82,7 @@ start_wlan() { static_ip="" # won't be used again else msg_done dhcp - dhclient -cf "$dh_conf" $os_wlan + dhclient -cf "$DH_CONF" $os_wlan fi if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_wlan | grep inet &>/dev/null; then @@ -120,12 +121,12 @@ start_eth() { done # wait for link - test "$link_watch" == "true" || link_nego_timeout=5 + test "$link_watch" == "true" || LINK_NEGO_TIMEOUT=5 count=0 while [[ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]]; do sleep 1 count=$(($count + 1)) - if [[ $count -ge $link_nego_timeout ]]; then + if [[ $count -ge $LINK_NEGO_TIMEOUT ]]; then msg_done "no link" return 1 fi @@ -141,7 +142,7 @@ start_eth() { static_ip="" # won't be used again else msg_done dhcp - dhclient -cf "$dh_conf" $os_eth + dhclient -cf "$DH_CONF" $os_eth fi if [[ "$link_watch" == "true" ]]; then diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index a7bd496f32..f7cbbeb4b0 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -1,13 +1,14 @@ #!/bin/bash -watch_conf="/data/etc/watch.conf" -netwatch_retries=3 -netwatch_timeout=5 -netwatch_interval=20 +WATCH_CONF="/data/etc/watch.conf" +NETWATCH_RETRIES=3 +NETWATCH_TIMEOUT=5 +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 fi @@ -15,15 +16,16 @@ test -n "$os_version" || source /etc/init.d/base test "$os_networkless" == "true" && exit 0 + watch() { count=0 - netwatch_retries=$(($netwatch_retries - 1)) + NETWATCH_RETRIES=$(($NETWATCH_RETRIES - 1)) while true; do - sleep $netwatch_interval - if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port /dev/null 2>&1; then + sleep $NETWATCH_INTERVAL + if nc -z -w $NETWATCH_TIMEOUT $netwatch_host $netwatch_port /dev/null 2>&1; then count=0 else - if [[ $count -lt $netwatch_retries ]]; then + if [[ $count -lt $NETWATCH_RETRIES ]]; then logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port" count=$(($count + 1)) continue diff --git a/board/common/overlay/etc/init.d/S43firewall b/board/common/overlay/etc/init.d/S43firewall index 6ff91fc33a..0557ce5813 100755 --- a/board/common/overlay/etc/init.d/S43firewall +++ b/board/common/overlay/etc/init.d/S43firewall @@ -1,18 +1,19 @@ #!/bin/bash -sys_conf="/etc/firewall.sh" -boot_conf="/boot/firewall.sh" -conf="/data/etc/firewall.sh" +SYS_CONF="/etc/firewall.sh" +BOOT_CONF="/boot/firewall.sh" +CONF="/data/etc/firewall.sh" + test -n "$os_version" || source /etc/init.d/base -prepare_conf $conf $sys_conf $boot_conf -test -f $conf || exit 0 +prepare_conf $CONF $SYS_CONF $BOOT_CONF +test -f $CONF || exit 0 start() { msg_begin "Starting firewall" - bash $conf + bash $CONF test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S45dnsmasq b/board/common/overlay/etc/init.d/S45dnsmasq index 3eea12d66f..9d1f0326d5 100755 --- a/board/common/overlay/etc/init.d/S45dnsmasq +++ b/board/common/overlay/etc/init.d/S45dnsmasq @@ -1,28 +1,28 @@ #!/bin/bash -sys_conf="/etc/dnsmasq.conf" -boot_conf="/boot/dnsmasq.conf" -conf="/data/etc/dnsmasq.conf" +SYS_CONF="/etc/dnsmasq.conf" +BOOT_CONF="/boot/dnsmasq.conf" +CONF="/data/etc/dnsmasq.conf" -log="/var/log/dnsmasq.log" -prog="/usr/sbin/dnsmasq" +LOG="/var/log/dnsmasq.log" +PROG="/usr/sbin/dnsmasq" test -n "$os_version" || source /etc/init.d/base -prepare_conf $conf $sys_conf $boot_conf -test -f $conf || exit 0 +prepare_conf $CONF $SYS_CONF $BOOT_CONF +test -f $CONF || exit 0 start() { msg_begin "Starting dnsmasq" - 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 + 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 ifconfig $iface $ip - $prog -C $conf --log-facility=$log + $PROG -C $CONF --log-facility=$LOG test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S50date b/board/common/overlay/etc/init.d/S50date index ad6324e4f6..5393314d1b 100755 --- a/board/common/overlay/etc/init.d/S50date +++ b/board/common/overlay/etc/init.d/S50date @@ -1,23 +1,23 @@ #!/bin/bash # 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" -boot_conf="/boot/date.conf" -conf="/data/etc/date.conf" +SYS_CONF="/etc/date.conf" +BOOT_CONF="/boot/date.conf" +CONF="/data/etc/date.conf" -sys_ntp_conf="/etc/ntp.conf" -boot_ntp_conf="/boot/ntp.conf" -ntp_conf="/data/etc/ntp.conf" +SYS_NTP_CONF="/etc/ntp.conf" +BOOT_NTP_CONF="/boot/ntp.conf" +NTP_CONF="/data/etc/ntp.conf" test -n "$os_version" || source /etc/init.d/base -prepare_conf $conf $sys_conf $boot_conf -prepare_conf $ntp_conf $sys_ntp_conf $boot_ntp_conf +prepare_conf $CONF $SYS_CONF $BOOT_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 @@ -26,23 +26,24 @@ date_method=http date_host="google.com" date_interval="900" -source $conf +source $CONF + 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: //') 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 $? } 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() { msg_begin "Setting current date using 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" while true; do @@ -55,23 +56,23 @@ start_http() { start_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 - echo "server $date_ntp_server iburst" > $ntp_conf + echo "server $date_ntp_server iburst" > $NTP_CONF else - cat $sys_ntp_conf | grep iburst > $ntp_conf + cat $SYS_NTP_CONF | grep iburst > $NTP_CONF fi - cat ${ntp_conf}.tmp >> $ntp_conf - rm ${ntp_conf}.tmp + cat ${NTP_CONF}.tmp >> $NTP_CONF + rm ${NTP_CONF}.tmp msg_begin "Setting current date using 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" - ntpd -g -c $ntp_conf + ntpd -g -c $NTP_CONF test $? == 0 && msg_done || msg_fail } @@ -94,7 +95,7 @@ start() { start_ntp 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() { diff --git a/board/common/overlay/etc/init.d/S51crond b/board/common/overlay/etc/init.d/S51crond index 618b482e12..5e464afc3f 100755 --- a/board/common/overlay/etc/init.d/S51crond +++ b/board/common/overlay/etc/init.d/S51crond @@ -1,19 +1,19 @@ #!/bin/bash -sys_conf="/etc/crontabs" -conf="/data/etc/crontabs" +SYS_CONF="/etc/crontabs" +CONF="/data/etc/crontabs" test -n "$os_version" || source /etc/init.d/base start() { msg_begin "Starting crond" - if [[ -d $sys_conf ]]; then - /usr/sbin/crond -c $sys_conf + if [[ -d $SYS_CONF ]]; then + /usr/sbin/crond -c $SYS_CONF fi - mkdir -p $conf - /usr/sbin/crond -c $conf + mkdir -p $CONF + /usr/sbin/crond -c $CONF test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S60sshd b/board/common/overlay/etc/init.d/S60sshd index 2dcd04ac7b..7acc266486 100755 --- a/board/common/overlay/etc/init.d/S60sshd +++ b/board/common/overlay/etc/init.d/S60sshd @@ -1,8 +1,8 @@ #!/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 @@ -22,7 +22,7 @@ start() { echo "Welcome to $hostname!" > /var/cache/sshd_banner sync - /usr/sbin/sshd -f $conf + /usr/sbin/sshd -f $CONF test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S98userinit b/board/common/overlay/etc/init.d/S98userinit index ffaf1dfb10..6dfcf08902 100755 --- a/board/common/overlay/etc/init.d/S98userinit +++ b/board/common/overlay/etc/init.d/S98userinit @@ -1,15 +1,16 @@ #!/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 case "$1" in start) msg_begin "Executing user init script" - /bin/bash $userinit_sh + /bin/bash $USERINIT test $? == 0 && msg_done || msg_fail ;; diff --git a/board/common/overlay/etc/init.d/os_conf b/board/common/overlay/etc/init.d/os_conf index 21713596b1..8d5f011674 100644 --- a/board/common/overlay/etc/init.d/os_conf +++ b/board/common/overlay/etc/init.d/os_conf @@ -1,20 +1,21 @@ -_sys_conf="/etc/os.conf" -_boot_conf="/boot/os.conf" -_data_conf="/data/etc/os.conf" +sys_conf="/etc/os.conf" +boot_conf="/boot/os.conf" +data_conf="/data/etc/os.conf" + # source in all conf files in order of precedence -if [[ -f $_sys_conf ]]; then - source $_sys_conf +if [[ -f $sys_conf ]]; then + source $sys_conf fi -if [[ -f $_data_conf ]]; then - source $_data_conf +if [[ -f $data_conf ]]; then + source $data_conf fi -if [[ -f $_boot_conf ]]; then - source $_boot_conf +if [[ -f $boot_conf ]]; then + source $boot_conf fi -unset _sys_conf _boot_conf _data_conf +unset sys_conf boot_conf data_conf