RTFM.WIKI

Ordnung muß sein. Ordnung über alles (18+)

User Tools

Site Tools


Sidebar


Навигация

Линкшэринг

ALARM!

Добавить новую страницу

You are not allowed to add pages
linux:bash:reboot_confirm

Подтверждение перезагрузки или выключения в Linux

Источник: https://matoski.com/article/confirm-before-executing-shutdown-reboot-linux/

Создаём bash скрипт /usr/local/bin/confirm

#!/usr/bin/env bash
echo "About to execute $1 command"
echo -n "Would you like to proceed y/n? "
read reply

if [ "$reply" = y -o "$reply" = Y ]
then
   $1 "${@:2}"
else
   echo "$1 ${@:2} cancelled"
fi

Создаём алиасы для команд

/etc/profile.d/confirm-shutdown.sh

alias shutdown="/usr/local/bin/confirm /sbin/shutdown"

/etc/profile.d/confirm-reboot.sh

alias reboot="/usr/local/bin/confirm /sbin/reboot"

Discussion

Enter your comment. Wiki syntax is allowed:
 
linux/bash/reboot_confirm.txt · Last modified: 2019/03/14 16:49 (external edit)