Вот сценарий < /p>
Код: Выделить всё
#!/bin/bash
# this script disables wifi and networking
echo 'Deleting all existing connections...'
# nmcli is a command-line interface for networkmanager
# 'nmcli connection delete' -> simply deletes a connection by ID, UUID or others
# we use 'nmcli connection show' along with some filter to extract UUIDs for all conections
# TODO enable deletion of a particular connection
#connections_list=$(nmcli connection show | grep -oP '\s(\S+-\S+-\S+-\S+-\S+)\s')
#for connection in "$connections_list"; do
#nmcli connection show "$connection"
#if (($? != 0)); then
#echo "something went wrong while deleting connection $connection" >&2
#exit 1
#fi
#done
nmcli connection delete $(nmcli connection show | grep -oP '\s(\S+-\S+-\S+-\S+-\S+)\s')
if [[ $? -ne 0 ]]; then
echo 'shit happens while deleting connections' >&1
exit 1
fi
echo 'All connections were deleted! now, you will have to type SSID and password again'
echo
echo 'Disabling Wi-Fi...'
if ! nmcli radio wifi off; then
echo 'nmcli, command disabling wifi, is not satisfied for some reason' >&2
exit 1
fi
echo 'Wi-Fi is disabled.'
echo
echo 'Disabling networking...'
if ! nmcli networking off; then
echo 'nmcli, command disabling networking, is not happy' >&2
exit 1
fi
echo 'Networking is disabled.'
echo
echo 'All is good'
echo '==============================='
exit 0
< /code>
Вот линия Corntab (созданная с использованием sudo crontab -e) < /p>
@reboot /home/noor/bin/go-offline-1.0 \>\> /home/noor/go-offline.log 2\>&1 Содержание файла журнала:
Deleting all existing connections...
Error: NetworkManager is not running.
Error: NetworkManager is not running.
shit happens while deleting connections
< /code>
Я думаю, что в точке выполнения моего скрипта в процессе загрузки NetWrokmanager еще не активируется. Я не вижу причин упомянуть его данные.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... work-conne
Мобильная версия