diff --git a/config/menu b/config/menu index 08a5457..7d3706b 100644 --- a/config/menu +++ b/config/menu @@ -6,6 +6,7 @@ options+=("Bash" "") options+=("Firewall" "") options+=("Users" "") options+=("Sudoers" "") +options+=("Systemd" "") if [ -f /usr/bin/Xorg ]; then options+=("XOrg" "") fi @@ -25,6 +26,7 @@ case $sel in 'Firewall') menu config/firewall/menu;; 'Users') menu config/users/menu;; 'Sudoers') menu config/sudoers/menu;; + 'Systemd') menu config/systemd/menu;; 'XOrg') menu config/xorg/menu;; 'Grub') nano /etc/default/grub if(confirm "Run grub-mkconfig -o /boot/grub/grub.cfg ?") then diff --git a/config/systemd/menu b/config/systemd/menu new file mode 100644 index 0000000..76f8913 --- /dev/null +++ b/config/systemd/menu @@ -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 diff --git a/config/systemd/timedatectl/menu b/config/systemd/timedatectl/menu new file mode 100644 index 0000000..3446f5a --- /dev/null +++ b/config/systemd/timedatectl/menu @@ -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 diff --git a/lib b/lib index 940ec31..f2da669 100644 --- a/lib +++ b/lib @@ -174,6 +174,17 @@ pressanykey(){ } +# $1 : filename +editfile(){ + editor=$EDITOR + if [ "$editor" == "" ]; then + editor="nano" + fi + echo "$editor $1" + $editor "$1" +} + + # $1 : servicename # $2 : [displayname] svcstart(){