install_easy: readonly system check

This commit is contained in:
bol-van 2021-11-16 11:46:40 +03:00
parent 294140de97
commit e6e8ca1d4a

View File

@ -184,6 +184,26 @@ check_system()
echo system is based on $SYSTEM echo system is based on $SYSTEM
} }
check_readonly_system()
{
local RO
echo \* checking readonly system
case $SYSTEM in
systemd)
[ -w "$SYSTEMD_SYSTEM_DIR" ] || RO=1
;;
openrc)
[ -w "$(dirname "$INIT_SCRIPT")" ] || RO=1
;;
esac
[ -z "$RO" ] || {
echo '!!! READONLY SYSTEM DETECTED !!!'
echo '!!! WILL NOT BE ABLE TO CONFIGURE STARTUP !!!'
echo '!!! MANUAL STARTUP CONFIGURATION IS REQUIRED !!!'
ask_yes_no N "do you want to continue" || exitp 5
}
}
check_bins() check_bins()
{ {
echo \* checking executables echo \* checking executables
@ -697,6 +717,7 @@ service_install_systemd()
{ {
echo \* installing zapret service echo \* installing zapret service
if [ -w "$SYSTEMD_SYSTEM_DIR" ] ; then
rm -f "$INIT_SCRIPT" rm -f "$INIT_SCRIPT"
ln -fs "$EXEDIR/init.d/systemd/zapret.service" "$SYSTEMD_SYSTEM_DIR" ln -fs "$EXEDIR/init.d/systemd/zapret.service" "$SYSTEMD_SYSTEM_DIR"
"$SYSTEMCTL" daemon-reload "$SYSTEMCTL" daemon-reload
@ -704,6 +725,9 @@ service_install_systemd()
echo could not enable systemd service echo could not enable systemd service
exitp 20 exitp 20
} }
else
echo '!!! READONLY SYSTEM DETECTED !!! CANNOT INSTALL SYSTEMD UNITS !!!'
fi
} }
service_stop_systemd() service_stop_systemd()
@ -729,6 +753,7 @@ timer_install_systemd()
{ {
echo \* installing zapret-list-update timer echo \* installing zapret-list-update timer
if [ -w "$SYSTEMD_SYSTEM_DIR" ] ; then
"$SYSTEMCTL" disable zapret-list-update.timer "$SYSTEMCTL" disable zapret-list-update.timer
"$SYSTEMCTL" stop zapret-list-update.timer "$SYSTEMCTL" stop zapret-list-update.timer
ln -fs "$EXEDIR/init.d/systemd/zapret-list-update.service" "$SYSTEMD_SYSTEM_DIR" ln -fs "$EXEDIR/init.d/systemd/zapret-list-update.service" "$SYSTEMD_SYSTEM_DIR"
@ -742,6 +767,9 @@ timer_install_systemd()
echo could not start zapret-list-update.timer echo could not start zapret-list-update.timer
exitp 30 exitp 30
} }
else
echo '!!! READONLY SYSTEM DETECTED !!! CANNOT INSTALL SYSTEMD UNITS !!!'
fi
} }
download_list() download_list()
@ -785,6 +813,7 @@ crontab_add()
[ -x "$GET_LIST" ] && { [ -x "$GET_LIST" ] && {
echo \* adding crontab entry echo \* adding crontab entry
if exists crontab; then
CRONTMP=/tmp/cron.tmp CRONTMP=/tmp/cron.tmp
crontab -l >$CRONTMP 2>/dev/null crontab -l >$CRONTMP 2>/dev/null
if grep -q "$GET_LIST_PREFIX" $CRONTMP; then if grep -q "$GET_LIST_PREFIX" $CRONTMP; then
@ -795,8 +824,10 @@ crontab_add()
echo "$(random 0 59) $(random $1 $2) */2 * * $GET_LIST" >>$CRONTMP echo "$(random 0 59) $(random $1 $2) */2 * * $GET_LIST" >>$CRONTMP
crontab $CRONTMP crontab $CRONTMP
fi fi
rm -f $CRONTMP rm -f $CRONTMP
else
echo '!!! CRON IS ABSENT !!! LISTS AUTO UPDATE WILL NOT WORK !!!'
fi
} }
} }
cron_ensure_running() cron_ensure_running()
@ -899,6 +930,7 @@ install_systemd()
check_bins check_bins
require_root require_root
check_readonly_system
check_location copy_all check_location copy_all
check_prerequisites_linux check_prerequisites_linux
service_stop_systemd service_stop_systemd
@ -968,6 +1000,7 @@ _install_sysv()
check_bins check_bins
require_root require_root
check_readonly_system
check_location copy_all check_location copy_all
check_prerequisites_linux check_prerequisites_linux
service_stop_sysv service_stop_sysv