From 2e036290d1489523f7aabced476e229fc64d4ab3 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 17:54:54 +0200 Subject: [PATCH 01/14] Small init scripts refactorization --- board/common/overlay/etc/init.d/S04syslog | 14 +++-- board/common/overlay/etc/init.d/S12udev | 18 +++--- board/common/overlay/etc/init.d/S13watchdog | 13 +++- board/common/overlay/etc/init.d/S30dbus | 17 ++++-- board/common/overlay/etc/init.d/S33hostapd | 6 +- board/common/overlay/etc/init.d/S35wifi | 3 +- board/common/overlay/etc/init.d/S36ppp | 6 +- board/common/overlay/etc/init.d/S37bluetooth | 39 ++++++------ board/common/overlay/etc/init.d/S41netwatch | 12 ++-- board/common/overlay/etc/init.d/S43firewall | 1 + board/common/overlay/etc/init.d/S45dnsmasq | 4 +- board/common/overlay/etc/init.d/S51crond | 12 +++- board/common/overlay/etc/init.d/S60sshd | 15 +++-- board/common/overlay/etc/init.d/S61proftpd | 52 ++++++++++++++++ board/common/overlay/etc/init.d/S62smb | 62 ++++++++++++++++++++ 15 files changed, 216 insertions(+), 58 deletions(-) create mode 100755 board/common/overlay/etc/init.d/S61proftpd create mode 100755 board/common/overlay/etc/init.d/S62smb diff --git a/board/common/overlay/etc/init.d/S04syslog b/board/common/overlay/etc/init.d/S04syslog index facaeedb98..78586fadf3 100755 --- a/board/common/overlay/etc/init.d/S04syslog +++ b/board/common/overlay/etc/init.d/S04syslog @@ -1,24 +1,28 @@ #!/bin/bash -test -n "${OS_VERSION}" || source /etc/init.d/base +PROG="/sbin/syslogd" +PROG_D="/bin/dmesg" DMESG_LOG="/var/log/dmesg.log" +test -n "${OS_VERSION}" || source /etc/init.d/base + + case "$1" in start) msg_begin "Starting syslogd" - syslogd + ${PROG} test $? == 0 && msg_done || msg_fail echo "---- booting ${OS_NAME} ${OS_VERSION} ----" >> ${DMESG_LOG} - dmesg -T -w >> ${DMESG_LOG} & + ${PROG_D} -T -w >> ${DMESG_LOG} & ;; stop) msg_begin "Stopping syslogd" - killall syslogd &>/dev/null + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail - killall dmesg &>/dev/null + killall -q $(basename ${PROG_D}) ;; *) diff --git a/board/common/overlay/etc/init.d/S12udev b/board/common/overlay/etc/init.d/S12udev index 3228aefc17..fecf68e5cc 100755 --- a/board/common/overlay/etc/init.d/S12udev +++ b/board/common/overlay/etc/init.d/S12udev @@ -1,31 +1,35 @@ #!/bin/bash -CONF=/etc/udev/udev.conf +CONF="/etc/udev/udev.conf" +PROG="/sbin/udevd" +PROG_UA="/sbin/udevadm" +test -f ${PROG} || exit 0 test -f ${CONF} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base source ${CONF} + start() { msg_begin "Starting eudev" echo '\000\000\000\000' > /proc/sys/kernel/hotplug - /sbin/udevd --daemon --resolve-names=never + ${PROG} --daemon --resolve-names=never test $? == 0 && msg_done || msg_fail - /sbin/udevadm trigger --type=subsystems --action=add - /sbin/udevadm trigger --type=devices --action=add - /sbin/udevadm settle --timeout=30 + ${PROG_UA} trigger --type=subsystems --action=add + ${PROG_UA} trigger --type=devices --action=add + ${PROG_UA} settle --timeout=30 return 0 } stop() { msg_begin "Stopping eudev" - udevadm control --stop-exec-queue - killall udevd &>/dev/null + ${PROG_UA} control --stop-exec-queue + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S13watchdog b/board/common/overlay/etc/init.d/S13watchdog index 331bdcfc66..4b5e686b6f 100755 --- a/board/common/overlay/etc/init.d/S13watchdog +++ b/board/common/overlay/etc/init.d/S13watchdog @@ -1,13 +1,20 @@ #!/bin/bash -test -c /dev/watchdog || exit 0 +DEV="/dev/watchdog" + +PROG="/sbin/watchdog" + + +test -c ${PROG} || exit 0 +test -c ${DEV} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base + case "$1" in start) msg_begin "Starting watchdog" - watchdog -t 5 /dev/watchdog + ${PROG} -t 5 ${DEV} test $? == 0 && msg_done || msg_fail ;; @@ -17,7 +24,7 @@ case "$1" in reallystop) msg_begin "Stopping watchdog" - killall watchdog &>/dev/null + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail ;; diff --git a/board/common/overlay/etc/init.d/S30dbus b/board/common/overlay/etc/init.d/S30dbus index 5f9bc53f4e..c239b80654 100755 --- a/board/common/overlay/etc/init.d/S30dbus +++ b/board/common/overlay/etc/init.d/S30dbus @@ -4,30 +4,35 @@ SYS_BTCONF="/etc/bluetooth.conf" BOOT_BTCONF="/boot/bluetooth.conf" BTCONF="/data/etc/bluetooth.conf" +PROG="/usr/bin/dbus-daemon" +PROG_UG="/usr/bin/dbus-uuidgen" +PROG_UA="/usr/bin/udevadm" + + +test -x ${PROG} || exit 0 # dbus is currently only used by bluez test -f ${BTCONF} || test -f ${BOOT_BTCONF} || test -f ${SYS_BTCONF} || exit 0 -test -x /usr/bin/dbus-daemon || exit 0 - test -n "${OS_VERSION}" || source /etc/init.d/base + start() { mkdir -p /tmp/dbus mkdir -p /var/lib/dbus msg_begin "Starting dbus" - dbus-uuidgen --ensure - dbus-daemon --system + ${PROG_UG} --ensure + ${PROG} --system test $? == 0 && msg_done || msg_fail } stop() { msg_begin "Stopping dbus" - udevadm control --stop-exec-queue - killall dbus-daemon &>/dev/null + ${PROG_UA} control --stop-exec-queue + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail rm -f /var/run/messagebus.pid diff --git a/board/common/overlay/etc/init.d/S33hostapd b/board/common/overlay/etc/init.d/S33hostapd index d25ffae608..c7da890c31 100755 --- a/board/common/overlay/etc/init.d/S33hostapd +++ b/board/common/overlay/etc/init.d/S33hostapd @@ -9,10 +9,12 @@ PROG="/usr/sbin/hostapd" WATCH_CONF="/data/etc/watch.conf" -link_watch=yes -link_watch_timeout=20 +LINK_WATCH=yes +LINK_WATCH_TIMEOUT=20 +test -x {$PROG} || exit 0 + test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} diff --git a/board/common/overlay/etc/init.d/S35wifi b/board/common/overlay/etc/init.d/S35wifi index 93294aad89..d1b6a3901c 100755 --- a/board/common/overlay/etc/init.d/S35wifi +++ b/board/common/overlay/etc/init.d/S35wifi @@ -13,6 +13,8 @@ BOOT_WATCH_CONF="/boot/watch.conf" WATCH_CONF="/data/etc/watch.conf" +test -x ${PROG} || exit 0 + test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${WATCH_CONF} ${SYS_WATCH_CONF} ${BOOT_WATCH_CONF} @@ -24,7 +26,6 @@ test -f ${CONF} || exit 0 ssid=$(cat ${CONF} | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) test -n "${ssid}" || exit 0 - test "${OS_NETWORKLESS}" == "true" && exit 0 diff --git a/board/common/overlay/etc/init.d/S36ppp b/board/common/overlay/etc/init.d/S36ppp index 14dbe7cd6c..9186e6e926 100755 --- a/board/common/overlay/etc/init.d/S36ppp +++ b/board/common/overlay/etc/init.d/S36ppp @@ -10,6 +10,8 @@ PROVIDER="mobile" WATCH_CONF="/data/etc/watch.conf" +test -x ${PROG} || exit 0 + test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} @@ -88,7 +90,7 @@ start() { break fi - if [[ ${count} -gt ${LINK_WATCH_TIMEOUT} ]] || ! pidof pppd > /dev/null; then + if [[ ${count} -gt ${LINK_WATCH_TIMEOUT} ]] || ! pidof $(basename ${PROG}) > /dev/null; then msg_fail return fi @@ -105,7 +107,7 @@ start() { stop() { msg_begin "Stopping pppd" - killall pppd &>/dev/null + killall -q $(basename ${PROG}) ps | grep ppp | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill msg_done } diff --git a/board/common/overlay/etc/init.d/S37bluetooth b/board/common/overlay/etc/init.d/S37bluetooth index 8d2fde898d..16cc5eab45 100755 --- a/board/common/overlay/etc/init.d/S37bluetooth +++ b/board/common/overlay/etc/init.d/S37bluetooth @@ -3,34 +3,35 @@ SYS_CONF="/etc/bluetooth.conf" BOOT_CONF="/boot/bluetooth.conf" CONF="/data/etc/bluetooth.conf" +RUN_CONF="/var/lib/bluetooth.conf" +ADAPTER="hci0" +PROG="/usr/libexec/bluetooth/bluetoothd" +PROG_HC="/usr/bin/hciconfig" +DATA_DIR="/var/lib/bluetooth" +RUN_DATA_DIR="/data/bluetooth" + + +test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} test -f ${CONF} || exit 0 -hci=hci0 -bluetoothd=/usr/libexec/bluetooth/bluetoothd -data_dir=/var/lib/bluetooth -run_data_dir=/data/bluetooth -run_conf=/var/lib/bluetooth.conf - -test -x ${bluetoothd} || exit 0 - configure() { - mkdir -p ${run_data_dir} - ln -sf ${run_data_dir} ${data_dir} - cp ${CONF} ${run_conf} + mkdir -p ${RUN_DATA_DIR} + ln -sf ${RUN_DATA_DIR} ${DATA_DIR} + cp ${CONF} ${RUN_CONF} # if no specific name configured, use hostname - if ! grep -E 'Name\s*=' ${run_conf} &>/dev/null; then - sed -ri "s/(\[General\])/\1\nName = $(hostname)/" ${run_conf} + if ! grep -E 'Name\s*=' ${RUN_CONF} &>/dev/null; then + sed -ri "s/(\[General\])/\1\nName = $(hostname)/" ${RUN_CONF} fi # bring adapter up - hciconfig ${hci} up + ${PROG_HC} ${ADAPTER} up } start() { @@ -38,7 +39,7 @@ start() { # wait up to 10 seconds for device count=0 - while ! hciconfig ${hci} &>/dev/null; do + while ! ${PROG_HC} ${ADAPTER} &>/dev/null; do sleep 1 count=$((${count} + 1)) if [[ ${count} -ge 10 ]]; then @@ -57,19 +58,19 @@ start() { fi msg_begin "Starting bluetoothd" - ${bluetoothd} &>/dev/null & + ${PROG} &>/dev/null & msg_done # if DiscoverableTimeout is set to 0, make adapter discoverable from boot time - if grep -E '^DiscoverableTimeout\s*=\s*0$' ${run_conf} &>/dev/null; then + if grep -E '^DiscoverableTimeout\s*=\s*0$' ${RUN_CONF} &>/dev/null; then sleep 1 - hciconfig ${hci} piscan + ${PROG_HC} ${ADAPTER} piscan fi } stop() { msg_begin "Stopping bluetoothd" - killall bluetoothd &>/dev/null + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index cfab7e3c91..bb2f18be17 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -1,16 +1,18 @@ #!/bin/bash -WATCH_CONF="/data/etc/watch.conf" +CONF="/data/etc/watch.conf" NETWATCH_RETRIES=3 NETWATCH_TIMEOUT=5 NETWATCH_INTERVAL=20 -test -f ${WATCH_CONF} && source ${WATCH_CONF} || exit 0 +# watch configuration is already prepared by wifi init script -if [[ -z "${NETWATCH_HOST}" || -z "${NETWATCH_PORT}" ]]; then - exit 0 -fi +test -f ${CONF} || exit 0 +source ${CONF} + +test -z "${NETWATCH_HOST}" || exit 0 +test -z "${NETWATCH_PORT}" || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base diff --git a/board/common/overlay/etc/init.d/S43firewall b/board/common/overlay/etc/init.d/S43firewall index c588fd0d6d..bab1a54053 100755 --- a/board/common/overlay/etc/init.d/S43firewall +++ b/board/common/overlay/etc/init.d/S43firewall @@ -10,6 +10,7 @@ test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} test -f ${CONF} || exit 0 + start() { msg_begin "Starting firewall" diff --git a/board/common/overlay/etc/init.d/S45dnsmasq b/board/common/overlay/etc/init.d/S45dnsmasq index df0d849cbe..f178f84a3f 100755 --- a/board/common/overlay/etc/init.d/S45dnsmasq +++ b/board/common/overlay/etc/init.d/S45dnsmasq @@ -8,6 +8,8 @@ LOG="/var/log/dnsmasq.log" PROG="/usr/sbin/dnsmasq" +test -x ${PROG} || exit 0 + test -n "${OS_VERSION}" || source /etc/init.d/base prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} @@ -29,7 +31,7 @@ start() { stop() { msg_begin "Stopping dnsmasq" - killall dnsmasq &>/dev/null + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S51crond b/board/common/overlay/etc/init.d/S51crond index 7485031ef7..9529ee31d8 100755 --- a/board/common/overlay/etc/init.d/S51crond +++ b/board/common/overlay/etc/init.d/S51crond @@ -3,24 +3,30 @@ SYS_CONF="/etc/crontabs" CONF="/data/etc/crontabs" +PROG="/usr/sbin/crond" + + +test -x ${PROG} || exit 0 + 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} + ${PROG} -c ${SYS_CONF} fi mkdir -p ${CONF} - /usr/sbin/crond -c ${CONF} + ${PROG} -c ${CONF} test $? == 0 && msg_done || msg_fail } stop() { msg_begin "Stopping crond" - killall crond &>/dev/null + killall -q $(basename ${PROG}) 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 3d7f7620c2..26709bd001 100755 --- a/board/common/overlay/etc/init.d/S60sshd +++ b/board/common/overlay/etc/init.d/S60sshd @@ -2,17 +2,24 @@ CONF="/etc/sshd_config" -test -f ${CONF} || exit 0 +PROG="/usr/sbin/sshd" +KGPROG="/usr/bin/ssh-keygen" + + +test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base +test -x ${CONF} || exit 0 + test "${OS_NETWORKLESS}" == "true" && exit 0 + start() { msg_begin "Starting sshd" # create any missing keys - if ! /usr/bin/ssh-keygen -A >/dev/null; then + if ! ${KGPROG} -A >/dev/null; then msg_fail return 1 fi @@ -22,13 +29,13 @@ start() { echo "Welcome to ${hostname}!" > /var/cache/sshd_banner sync - /usr/sbin/sshd -f ${CONF} + ${PROG} -f ${CONF} test $? == 0 && msg_done || msg_fail } stop() { msg_begin "Stopping sshd" - killall sshd &>/dev/null + killall -q $(basename ${PROG}) test $? == 0 && msg_done || msg_fail } diff --git a/board/common/overlay/etc/init.d/S61proftpd b/board/common/overlay/etc/init.d/S61proftpd new file mode 100755 index 0000000000..e83b05451b --- /dev/null +++ b/board/common/overlay/etc/init.d/S61proftpd @@ -0,0 +1,52 @@ +#!/bin/bash + +CONF="/etc/proftpd.conf" +PROG="/usr/sbin/proftpd" + + +test -x ${PROG} || exit 0 + +test -n "${OS_VERSION}" || source /etc/init.d/base +test -n "${OS_DEBUG}" || source /etc/init.d/conf + +test -x ${CONF} || exit 0 + +test "${OS_NETWORKLESS}" == "true" && exit 0 + + +start() { + msg_begin "Starting proftpd" + mkdir -p /var/run/proftpd + touch /var/log/wtmp + ${PROG} &>/dev/null + test $? == 0 && msg_done || msg_fail +} + +stop() { + msg_begin "Stopping proftpd" + killall -q $(basename ${PROG}) + test $? == 0 && msg_done || msg_fail +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 + diff --git a/board/common/overlay/etc/init.d/S62smb b/board/common/overlay/etc/init.d/S62smb new file mode 100755 index 0000000000..1135975435 --- /dev/null +++ b/board/common/overlay/etc/init.d/S62smb @@ -0,0 +1,62 @@ +#!/bin/bash + +CONF="/etc/samba/smb.conf" + +PROG="/usr/sbin/smbd" +PROG_N="/usr/sbin/nmbd" + + +test -x ${PROG} || exit 0 + +test -n "${OS_VERSION}" || source /etc/init.d/base +test -n "${OS_DEBUG}" || source /etc/init.d/conf + +test -x ${CONF} || exit 0 + +test "${OS_NETWORKLESS}" == "true" && exit 0 + + +start() { + mkdir -p /var/log/samba + mkdir -p /var/lib/samba/private + + msg_begin "Starting smbd" + ${PROG} -D + test $? == 0 && msg_done || msg_fail + + msg_begin "Starting nmbd" + ${PROG_N} -D + test $? == 0 && msg_done || msg_fail +} + +stop() { + msg_begin "Stopping smbd" + killall -q $(basename ${PROG}) + test $? == 0 && msg_done || msg_fail + + msg_begin "Stopping nmbd" + killall -q $(basename ${PROG_N}) + test $? == 0 && msg_done || msg_fail +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $? + From 467391458e78a14aa2a916347f0b3a8ac228ec8e Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 18:13:03 +0200 Subject: [PATCH 02/14] Add redis & mongo init scripts --- board/common/overlay/etc/init.d/S70mongod | 50 +++++++++++++++++++++++ board/common/overlay/etc/init.d/S71redis | 50 +++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100755 board/common/overlay/etc/init.d/S70mongod create mode 100755 board/common/overlay/etc/init.d/S71redis diff --git a/board/common/overlay/etc/init.d/S70mongod b/board/common/overlay/etc/init.d/S70mongod new file mode 100755 index 0000000000..ce2b6cbb22 --- /dev/null +++ b/board/common/overlay/etc/init.d/S70mongod @@ -0,0 +1,50 @@ +#!/bin/bash + +SYS_CONF="/etc/mongodb.conf" +BOOT_CONF="/boot/mongodb.conf" +CONF="/data/etc/mongodb.conf" + +PROG="/usr/bin/mongod" + + +test -x {$PROG} || exit 0 + +test -n "${OS_VERSION}" || source /etc/init.d/base + +prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} +test -f ${CONF} || exit 0 + + +start() { + msg_begin "Starting mongod" + db_dir=$(cat ${CONF} | grep dbpath | cut -d '=' -f 2) + mkdir -p ${db_dir} + ${PROG} -f ${CONF} --fork > /dev/null + test $? == 0 && msg_done || msg_fail +} + +stop() { + msg_begin "Stopping mongod" + killall -q $(basename ${PROG}) + test $? == 0 && msg_done || msg_fail +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + diff --git a/board/common/overlay/etc/init.d/S71redis b/board/common/overlay/etc/init.d/S71redis new file mode 100755 index 0000000000..aa26670fff --- /dev/null +++ b/board/common/overlay/etc/init.d/S71redis @@ -0,0 +1,50 @@ +#!/bin/bash + +SYS_CONF="/etc/redis.conf" +BOOT_CONF="/boot/redis.conf" +CONF="/data/etc/redis.conf" + +PROG="/usr/bin/redis-server" + + +test -x {$PROG} || exit 0 + +test -n "${OS_VERSION}" || source /etc/init.d/base + +prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} +test -f ${CONF} || exit 0 + + +start() { + msg_begin "Starting redis" + db_dir=$(cat ${CONF} | grep -E '^dir' | cut -d ' ' -f 2) + mkdir -p ${db_dir} + ${PROG} ${CONF} + test $? == 0 && msg_done || msg_fail +} + +stop() { + msg_begin "Stopping redis" + killall -q $(basename ${PROG}) + test $? == 0 && msg_done || msg_fail +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + From 235ff3a799d55eefb639a9d041e6c58ea3e0bc99 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 18:48:37 +0200 Subject: [PATCH 03/14] Cleanup S50redis init script --- board/common/cleanups.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/board/common/cleanups.sh b/board/common/cleanups.sh index 2a8e6925cb..d7cb52e12a 100755 --- a/board/common/cleanups.sh +++ b/board/common/cleanups.sh @@ -201,6 +201,7 @@ rm -f ${TARGET}/etc/init.d/S20urandom rm -f ${TARGET}/etc/init.d/S49ntp rm -f ${TARGET}/etc/init.d/S50sshd rm -f ${TARGET}/etc/init.d/S50proftpd +rm -f ${TARGET}/etc/init.d/S50redis rm -f ${TARGET}/etc/init.d/S80dhcp-relay rm -f ${TARGET}/etc/init.d/S80dhcp-server rm -f ${TARGET}/etc/init.d/S80dnsmasq From 692f0c8f2c3e6e676d63b2432d5c48abdf1660f0 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 21:38:22 +0200 Subject: [PATCH 04/14] Various init script fixes --- board/common/overlay/etc/init.d/S33hostapd | 2 +- board/common/overlay/etc/init.d/S41netwatch | 4 ++-- board/common/overlay/etc/init.d/S60sshd | 6 +++--- board/common/overlay/etc/init.d/S61proftpd | 2 +- board/common/overlay/etc/init.d/S62smb | 2 +- board/common/overlay/etc/init.d/S70mongod | 2 +- board/common/overlay/etc/init.d/S71redis | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/board/common/overlay/etc/init.d/S33hostapd b/board/common/overlay/etc/init.d/S33hostapd index c7da890c31..e864dd0ff1 100755 --- a/board/common/overlay/etc/init.d/S33hostapd +++ b/board/common/overlay/etc/init.d/S33hostapd @@ -13,7 +13,7 @@ LINK_WATCH=yes LINK_WATCH_TIMEOUT=20 -test -x {$PROG} || exit 0 +test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index bb2f18be17..f452c0bab8 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -11,8 +11,8 @@ NETWATCH_INTERVAL=20 test -f ${CONF} || exit 0 source ${CONF} -test -z "${NETWATCH_HOST}" || exit 0 -test -z "${NETWATCH_PORT}" || exit 0 +test -n "${NETWATCH_HOST}" || exit 0 +test -n "${NETWATCH_PORT}" || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base diff --git a/board/common/overlay/etc/init.d/S60sshd b/board/common/overlay/etc/init.d/S60sshd index 26709bd001..0c68a5446a 100755 --- a/board/common/overlay/etc/init.d/S60sshd +++ b/board/common/overlay/etc/init.d/S60sshd @@ -3,14 +3,14 @@ CONF="/etc/sshd_config" PROG="/usr/sbin/sshd" -KGPROG="/usr/bin/ssh-keygen" +PROG_KG="/usr/bin/ssh-keygen" test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base -test -x ${CONF} || exit 0 +test -f ${CONF} || exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0 @@ -19,7 +19,7 @@ start() { msg_begin "Starting sshd" # create any missing keys - if ! ${KGPROG} -A >/dev/null; then + if ! ${PROG_KG} -A >/dev/null; then msg_fail return 1 fi diff --git a/board/common/overlay/etc/init.d/S61proftpd b/board/common/overlay/etc/init.d/S61proftpd index e83b05451b..9835df2fc3 100755 --- a/board/common/overlay/etc/init.d/S61proftpd +++ b/board/common/overlay/etc/init.d/S61proftpd @@ -9,7 +9,7 @@ test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_DEBUG}" || source /etc/init.d/conf -test -x ${CONF} || exit 0 +test -f ${CONF} || exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0 diff --git a/board/common/overlay/etc/init.d/S62smb b/board/common/overlay/etc/init.d/S62smb index 1135975435..e203b5556c 100755 --- a/board/common/overlay/etc/init.d/S62smb +++ b/board/common/overlay/etc/init.d/S62smb @@ -11,7 +11,7 @@ test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base test -n "${OS_DEBUG}" || source /etc/init.d/conf -test -x ${CONF} || exit 0 +test -f ${CONF} || exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0 diff --git a/board/common/overlay/etc/init.d/S70mongod b/board/common/overlay/etc/init.d/S70mongod index ce2b6cbb22..0b9fbaea90 100755 --- a/board/common/overlay/etc/init.d/S70mongod +++ b/board/common/overlay/etc/init.d/S70mongod @@ -7,7 +7,7 @@ CONF="/data/etc/mongodb.conf" PROG="/usr/bin/mongod" -test -x {$PROG} || exit 0 +test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base diff --git a/board/common/overlay/etc/init.d/S71redis b/board/common/overlay/etc/init.d/S71redis index aa26670fff..6ba7a1d0a6 100755 --- a/board/common/overlay/etc/init.d/S71redis +++ b/board/common/overlay/etc/init.d/S71redis @@ -7,7 +7,7 @@ CONF="/data/etc/redis.conf" PROG="/usr/bin/redis-server" -test -x {$PROG} || exit 0 +test -x ${PROG} || exit 0 test -n "${OS_VERSION}" || source /etc/init.d/base From dc4a2f5b5f72ea5914b966c3a4f02679758d187b Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 23:34:47 +0200 Subject: [PATCH 05/14] python-mock: add host-python-pbr to deps --- package/python-mock/python-mock.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/package/python-mock/python-mock.mk b/package/python-mock/python-mock.mk index 564e11c68d..60791d2dd6 100644 --- a/package/python-mock/python-mock.mk +++ b/package/python-mock/python-mock.mk @@ -10,5 +10,6 @@ PYTHON_MOCK_SITE = https://files.pythonhosted.org/packages/0c/53/014354fc93c591c PYTHON_MOCK_SETUP_TYPE = setuptools PYTHON_MOCK_LICENSE = Apache-2.0 PYTHON_MOCK_LICENSE_FILES = LICENSE.txt +PYTHON_MOCK_DEPENDENCIES = host-python-pbr $(eval $(python-package)) From c9d33c5b74b4438d04fd0c938efec526bb107c9d Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 23:39:38 +0200 Subject: [PATCH 06/14] python-apispec: add patch for fixing setup encoding --- package/python-apispec/0001-fix-setup-encoding.patch | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/python-apispec/0001-fix-setup-encoding.patch diff --git a/package/python-apispec/0001-fix-setup-encoding.patch b/package/python-apispec/0001-fix-setup-encoding.patch new file mode 100644 index 0000000000..835b114f7d --- /dev/null +++ b/package/python-apispec/0001-fix-setup-encoding.patch @@ -0,0 +1,12 @@ +diff -uNr apispec-0.39.0-orig/setup.py apispec-0.39.0-patched/setup.py +--- apispec-0.39.0-orig/setup.py 2018-06-29 05:50:26.000000000 +0300 ++++ apispec-0.39.0-patched/setup.py 2019-01-24 23:36:41.947206745 +0200 +@@ -13,7 +13,7 @@ + Raises RuntimeError if not found. + """ + version = '' +- with open(fname, 'r') as fp: ++ with open(fname, 'r', encoding='utf-8') as fp: + reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]') + for line in fp: + m = reg.match(line) From a0f27144fcd43d51480a8c37e3c5f231ad2f52ab Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 23:42:02 +0200 Subject: [PATCH 07/14] python-mock: fix Config deps --- package/python-mock/Config.in | 1 - 1 file changed, 1 deletion(-) diff --git a/package/python-mock/Config.in b/package/python-mock/Config.in index 0b6a3bd1a3..5292a26a22 100644 --- a/package/python-mock/Config.in +++ b/package/python-mock/Config.in @@ -1,7 +1,6 @@ config BR2_PACKAGE_PYTHON_MOCK bool "python-mock" depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3 - depends on BR2_PACKAGE_PYTHON_PBR help mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. From 244958bd117cfc216f2bdf4d5b7494907030efe9 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Thu, 24 Jan 2019 23:55:30 +0200 Subject: [PATCH 08/14] cleanup.sh: remove unused redis binaries --- board/common/cleanups.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/board/common/cleanups.sh b/board/common/cleanups.sh index d7cb52e12a..cba6420b92 100755 --- a/board/common/cleanups.sh +++ b/board/common/cleanups.sh @@ -170,10 +170,17 @@ rm -f ${TARGET}/usr/bin/wbinfo rm -f ${TARGET}/usr/sbin/winbindd rm -rf ${TARGET}/usr/share/ctdb -# useless mongodb binaries +# unused mongodb binaries rm -f ${TARGET}/usr/bin/mongos rm -f ${TARGET}/usr/bin/mongoperf +# unused redis binaries +rm -f $TARGET/usr/bin/redis-check-aof +rm -f $TARGET/usr/bin/redis-check-rdb +rm -f $TARGET/usr/bin/redis-benchmark +rm -f $TARGET/usr/bin/redis-cli +rm -f $TARGET/usr/bin/redis-sentinel + # v4l-utils rm -f ${TARGET}/usr/bin/cec-compliance rm -f ${TARGET}/usr/bin/cec-ctl From a051dabe09eb23a2aff77d74ec1d677dd99535b6 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 17:18:40 +0200 Subject: [PATCH 09/14] Tinkerboard: update kernel and remove unnecessary patch --- .../tinkerboard/linux-fix-ethernet-operstate.patch | 13 ------------- configs/tinkerboard_defconfig | 6 +++--- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 board/tinkerboard/linux-fix-ethernet-operstate.patch diff --git a/board/tinkerboard/linux-fix-ethernet-operstate.patch b/board/tinkerboard/linux-fix-ethernet-operstate.patch deleted file mode 100644 index b066366422..0000000000 --- a/board/tinkerboard/linux-fix-ethernet-operstate.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -index 2844b497464d..a4b0bb432368 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -@@ -3060,6 +3060,8 @@ int stmmac_dvr_probe(struct device *device, - goto error_netdev_register; - } - -+ netif_carrier_off(ndev); -+ - wake_lock_init(&priv->plat->wol_wake_lock, WAKE_LOCK_SUSPEND, "wol_wake_lock"); - - return ret; diff --git a/configs/tinkerboard_defconfig b/configs/tinkerboard_defconfig index db9ee4a4d2..e7c8d39272 100644 --- a/configs/tinkerboard_defconfig +++ b/configs/tinkerboard_defconfig @@ -2,17 +2,17 @@ BR2_arm=y BR2_cortex_a17=y BR2_ARM_FPU_NEON_VFPV4=y BR2_CCACHE=y -BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-bananapim1" +BR2_CCACHE_DIR="$(TOPDIR)/.buildroot-ccache-tinkerboard" BR2_OPTIMIZE_2=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TARGET_OPTIMIZATION="-pipe" BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y BR2_TARGET_TZ_INFO=y -BR2_ROOTFS_OVERLAY="board/common/overlay board/bananapim1/overlay" +BR2_ROOTFS_OVERLAY="board/common/overlay board/tinkerboard/overlay" BR2_ROOTFS_POST_BUILD_SCRIPT="board/common/postscript.sh" BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_TARBALL=y -BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/TinkerBoard/debian_kernel/archive/4cf992a71ecfed2a817219cf83aba5bf8c5d1d69.tar.gz" +BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/TinkerBoard/debian_kernel/archive/1a0fdafdf55afa88272fb61c8b910ed885d7fada.tar.gz" BR2_LINUX_KERNEL_DEFCONFIG="miniarm-rk3288" BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_INTREE_DTS_NAME="rk3288-miniarm" From fcf5807caaa17390c0908ed55563c611ef854685 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 19:55:30 +0200 Subject: [PATCH 10/14] build.sh: cleanup /var/lib symlink before build --- build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.sh b/build.sh index d1d3a4866a..a63b327624 100755 --- a/build.sh +++ b/build.sh @@ -66,6 +66,13 @@ if ! [ -f $basedir/configs/${board}_defconfig ]; then exit 1 fi +function prepare_target_dir() { + if [ -L $outputdir/target/var/lib ]; then + rm $outputdir/target/var/lib + mkdir $outputdir/target/var/lib + fi +} + mkdir -p $outputdir if ! [ -f $outputdir/.config ]; then @@ -135,9 +142,11 @@ elif [[ "$target" == initramfs* ]]; then fi elif [ "$target" == "all" ]; then + prepare_target_dir make O=$outputdir all elif [ -n "$target" ]; then + prepare_target_dir make O=$outputdir $target else # if [ -z "$target ] From ccaf32fe2a6299c4522215cf8265ebe815e55e91 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 20:24:59 +0200 Subject: [PATCH 11/14] busybox: enable su --- board/common/busybox.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/common/busybox.config b/board/common/busybox.config index c93a93c1ac..1a3a02eda5 100644 --- a/board/common/busybox.config +++ b/board/common/busybox.config @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Busybox version: 1.29.2 -# Wed Nov 14 23:22:52 2018 +# Fri Jan 25 20:24:12 2019 # CONFIG_HAVE_DOT_CONFIG=y @@ -525,7 +525,7 @@ CONFIG_FEATURE_NOLOGIN=y CONFIG_FEATURE_SECURETTY=y CONFIG_PASSWD=y # CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set -# CONFIG_SU is not set +CONFIG_SU=y # CONFIG_FEATURE_SU_SYSLOG is not set # CONFIG_FEATURE_SU_CHECKS_SHELLS is not set # CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set From 29541688bf871569fa4655aec54129714f93225c Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 22:28:53 +0200 Subject: [PATCH 12/14] Add postgresql init script --- board/common/cleanups.sh | 1 + board/common/overlay/etc/init.d/S72postgresql | 69 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 board/common/overlay/etc/init.d/S72postgresql diff --git a/board/common/cleanups.sh b/board/common/cleanups.sh index cba6420b92..ef7a8fee2d 100755 --- a/board/common/cleanups.sh +++ b/board/common/cleanups.sh @@ -208,6 +208,7 @@ rm -f ${TARGET}/etc/init.d/S20urandom rm -f ${TARGET}/etc/init.d/S49ntp rm -f ${TARGET}/etc/init.d/S50sshd rm -f ${TARGET}/etc/init.d/S50proftpd +rm -f ${TARGET}/etc/init.d/S50postgresql rm -f ${TARGET}/etc/init.d/S50redis rm -f ${TARGET}/etc/init.d/S80dhcp-relay rm -f ${TARGET}/etc/init.d/S80dhcp-server diff --git a/board/common/overlay/etc/init.d/S72postgresql b/board/common/overlay/etc/init.d/S72postgresql new file mode 100755 index 0000000000..b0f38d04a4 --- /dev/null +++ b/board/common/overlay/etc/init.d/S72postgresql @@ -0,0 +1,69 @@ +#!/bin/bash + +BOOT_CONF="/boot/postgresql.conf" +SYS_CONF="/etc/postgresql.conf" +CONF="/data/etc/postgresql.conf" + +PROG="/usr/bin/pg_ctl" + +DB_DIR="/var/lib/postgresql" +USER="postgres" +LOG="/var/log/postgresql.log" + + +function run_pg_ctl() { + su ${USER} -c "pg_ctl $*" +} + + +test -x ${PROG} || exit 0 + +test -n "${OS_VERSION}" || source /etc/init.d/base + +prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF} + + +start() { + mkdir -p ${DB_DIR} + chown -R ${USER} ${DB_DIR} + touch ${LOG} + chown ${USER} ${LOG} + + if [[ ! -f ${DB_DIR}/PG_VERSION ]]; then + msg_begin "Initializing postgresql db" + run_pg_ctl initdb -s -D ${DB_DIR} &>> ${LOG} + test $? == 0 && msg_done || msg_fail + + echo "include_if_exists = '/data/etc/postgresql.conf'" >> ${DB_DIR}/postgresql.conf + fi + + msg_begin "Starting postgresql" + run_pg_ctl start -s -D ${DB_DIR} -l ${LOG} + test $? == 0 && msg_done || msg_fail +} + +stop() { + msg_begin "Stopping postgresql" + run_pg_ctl stop -s -D ${DB_DIR} -m fast &>> ${LOG} + test $? == 0 && msg_done || msg_fail +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + restart) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + From f67bf5076e58924d6f3eb236e84761717ff04cea Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 22:54:09 +0200 Subject: [PATCH 13/14] Fix posgtres init script --- board/common/overlay/etc/init.d/S72postgresql | 1 + 1 file changed, 1 insertion(+) diff --git a/board/common/overlay/etc/init.d/S72postgresql b/board/common/overlay/etc/init.d/S72postgresql index b0f38d04a4..b6b61b82ce 100755 --- a/board/common/overlay/etc/init.d/S72postgresql +++ b/board/common/overlay/etc/init.d/S72postgresql @@ -28,6 +28,7 @@ start() { chown -R ${USER} ${DB_DIR} touch ${LOG} chown ${USER} ${LOG} + cd ${DB_DIR} if [[ ! -f ${DB_DIR}/PG_VERSION ]]; then msg_begin "Initializing postgresql db" From a7056fef64f5b363bfe46393a5bdb9a0df1f1ade Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Fri, 25 Jan 2019 23:01:13 +0200 Subject: [PATCH 14/14] postscript.sh: do not add admin to passwd more than once --- board/common/postscript.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board/common/postscript.sh b/board/common/postscript.sh index a10cee1305..10c18e9194 100755 --- a/board/common/postscript.sh +++ b/board/common/postscript.sh @@ -48,5 +48,7 @@ if [ -r ${BOARD_DIR}/os.conf ]; then fi # add admin user alias -echo "admin:x:0:0:root:/root:/bin/sh" >> ${TARGET}/etc/passwd +if ! grep -E '^admin:' ${TARGET}/etc/passwd &> /dev/null; then + echo "admin:x:0:0:root:/root:/bin/sh" >> ${TARGET}/etc/passwd +fi