Config : Add Systemd timedatectl

This commit is contained in:
MatMoul 2018-09-16 00:20:14 +02:00
parent b0f495a6d8
commit 11e5acc160
4 changed files with 74 additions and 0 deletions

View file

@ -6,6 +6,7 @@ options+=("Bash" "")
options+=("Firewall" "") options+=("Firewall" "")
options+=("Users" "") options+=("Users" "")
options+=("Sudoers" "") options+=("Sudoers" "")
options+=("Systemd" "")
if [ -f /usr/bin/Xorg ]; then if [ -f /usr/bin/Xorg ]; then
options+=("XOrg" "") options+=("XOrg" "")
fi fi
@ -25,6 +26,7 @@ case $sel in
'Firewall') menu config/firewall/menu;; 'Firewall') menu config/firewall/menu;;
'Users') menu config/users/menu;; 'Users') menu config/users/menu;;
'Sudoers') menu config/sudoers/menu;; 'Sudoers') menu config/sudoers/menu;;
'Systemd') menu config/systemd/menu;;
'XOrg') menu config/xorg/menu;; 'XOrg') menu config/xorg/menu;;
'Grub') nano /etc/default/grub 'Grub') nano /etc/default/grub
if(confirm "Run grub-mkconfig -o /boot/grub/grub.cfg ?") then if(confirm "Run grub-mkconfig -o /boot/grub/grub.cfg ?") then

20
config/systemd/menu Normal file
View file

@ -0,0 +1,20 @@
#!/bin/bash
. ./lib
options=()
options+=("timedatectl" "")
defaultitem="timedatectl"
sel=$(whiptail --backtitle "$apptitle" --title "Systemd Menu :" --menu "" --default-item "$defaultitem" --cancel-button "Back" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0
case $sel in
'timedatectl') menu config/systemd/timedatectl/menu;;
esac
exit 0

View file

@ -0,0 +1,41 @@
#!/bin/bash
. ./lib
options=()
timedatectl status | grep inactive> /dev/null
if [ "$?" = "0" ]; then
options+=("Enable" "timedatectl set-ntp true")
else
options+=("Disable" "timedatectl set-ntp false")
fi
options+=("Edit" "/etc/systemd/timesyncd.conf")
defaultitem="timedatectl"
sel=$(whiptail --backtitle "$apptitle" --title "Systemd timedatectl Menu :" --menu "" --default-item "$defaultitem" --cancel-button "Back" 0 0 0 \
"${options[@]}" \
3>&1 1>&2 2>&3)
if [ ! "$?" = "0" ]; then
exit 1
fi
sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0
case $sel in
'Enable')
clear
echo "timedatectl set-ntp true"
timedatectl set-ntp true
pressanykey
;;
'Disable')
clear
echo "timedatectl set-ntp false"
timedatectl set-ntp false
pressanykey
;;
'Edit')
clear
editfile /etc/systemd/timesyncd.conf
pressanykey
esac
exit 0

11
lib
View file

@ -174,6 +174,17 @@ pressanykey(){
} }
# $1 : filename
editfile(){
editor=$EDITOR
if [ "$editor" == "" ]; then
editor="nano"
fi
echo "$editor $1"
$editor "$1"
}
# $1 : servicename # $1 : servicename
# $2 : [displayname] # $2 : [displayname]
svcstart(){ svcstart(){