galeb

Једноставна статичка дистрибуција заснована на musl-у
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување b9f9d7e6ba63b1c33ce2c7305a76ad82e01e5cd4
родитељ 8048b41887587ece3a9abd2b498d366b343202e2
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed, 27 Jul 2022 21:14:55 +0200

More thorough tmux detection; fix logfile creation

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Mfil/rc.d/g_fun.sh | 45++++++++++++++++++++++++++++++++++++++++-----
Mfil/rc.d/rc.init | 4+++-
Mfil/rc.d/rc.shutdown | 2+-
измењених датотека: 3, додавања: 44(+), брисања: 7(-)

diff --git a/fil/rc.d/g_fun.sh b/fil/rc.d/g_fun.sh @@ -14,11 +14,15 @@ white=$(printf '\033[97m') bgyellow=$(printf '\033[103m') bgwhite=$(printf '\033[107m') -if [ -n "${RCINIT}" ]; then - G_LOGFILE=/tmp/boot.log -else - G_LOGFILE=/dev/null -fi +LOGFILE=/tmp/boot.log +G_LOGFILE=/dev/null + +create_logfile() +{ + G_LOGFILE=${LOGFILE} + export G_LOGFILE + :>${G_LOGFILE} +} msg() { @@ -70,3 +74,34 @@ msg() fi } +parents() +{ + pid=$1 + if [ -z "$pid" ]; then + pid=$$ + fi + + ppid=$(ps -ef | awk '{if ($2=='$pid') print $3}') + echo $ppid + if [ $ppid -ne 1 ]; then + parents $ppid + fi +} + +intmux() +{ + local intmux=0 + for pid in $(parents); do + line=$(ps -ef | awk '{if ($2=='$pid') print}') + case $line in + *intmux*) ;; + *tmux*) intmux=1;; + *) ;; + esac + done + if [ ${intmux} -eq 1 ]; then + return 0 + else + return 1 + fi +} diff --git a/fil/rc.d/rc.init b/fil/rc.d/rc.init @@ -24,7 +24,9 @@ mkdir -p /dev/pts mount -n -t devpts -o nosuid,noexec,noatime,gid=5,mode=0620 devpts /dev/pts mount -n -t tmpfs -o nosuid,nodev,noatime,mode=0755 run /var/run -printf "%s: %s created on %s\n" $0 "${GOOTLOG}" "$(date)" >/tmp/boot.log +create_logfile + +printf "%s: %s created on %s\n" $0 "${G_LOGFILE}" "$(date)" >${G_LOGFILE} if grep -q verbose /proc/cmdline >/dev/null 2>>${G_LOGFILE}; then dmesg -n 8 2>>${G_LOGFILE} diff --git a/fil/rc.d/rc.shutdown b/fil/rc.d/rc.shutdown @@ -11,7 +11,7 @@ export PATH if [ "$(id -u)" -ne 0 ]; then msg err "You must be root to run $0" exit 2 -elif [ -n "${TMUX}" ]; then +elif intmux; then msg err "Exit tmux first" exit 2 fi