From be940d8e2942560cccf1d3009dcab965650148df Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sun, 16 Sep 2018 03:36:14 +0200 Subject: [PATCH] Project : Update edit command --- config/bash/editor | 16 ++++++++++++---- config/firewall/menu | 8 ++++---- config/menu | 2 +- config/sudoers/menu | 4 ++-- config/xorg/menu | 4 ++-- install/console/generic | 1 + install/system/services/menu | 4 ++-- updates/menu | 4 ++-- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/config/bash/editor b/config/bash/editor index 8e2fb2f..07f7f2f 100644 --- a/config/bash/editor +++ b/config/bash/editor @@ -2,10 +2,18 @@ . ./lib options=() -options+=("nano" "") -options+=("vim" "") -options+=("vi" "") -options+=("edit" "") +if [ -f /usr/bin/nano ]; then + options+=("nano" "") +fi +if [ -f /usr/bin/vim ]; then + options+=("vim" "") +fi +if [ -f /usr/bin/vi ]; then + options+=("vi" "") +fi +if [ -f /usr/bin/edit ]; then + options+=("edit" "") +fi options+=("unset" "") editor=$(whiptail --backtitle "$apptitle" --title "Default global editor :" --menu "" --cancel-button "Back" 0 0 0 \ diff --git a/config/firewall/menu b/config/firewall/menu index 2e3cfc3..22aafff 100644 --- a/config/firewall/menu +++ b/config/firewall/menu @@ -2,8 +2,8 @@ . ./lib options=() -options+=("Edit IPv4" "nano /etc/iptables/iptables.rules") -options+=("Edit IPv6" "nano /etc/iptables/ip6tables.rules") +options+=("Edit IPv4" "/etc/iptables/iptables.rules") +options+=("Edit IPv6" "/etc/iptables/ip6tables.rules") options+=("" "") options+=("Load Rules" "iptables-restore & ip6tables-restore") options+=("" "") @@ -20,8 +20,8 @@ fi sed -i "/^defaultitem=/c\defaultitem=\"$sel\"" $0 case $sel in - 'Edit IPv4') nano /etc/iptables/iptables.rules;; - 'Edit IPv6') nano /etc/iptables/ip6tables.rules;; + 'Edit IPv4') editfile /etc/iptables/iptables.rules;; + 'Edit IPv6') editfile /etc/iptables/ip6tables.rules;; 'Load Rules') iptables-restore < /etc/iptables/iptables.rules ip6tables-restore < /etc/iptables/ip6tables.rules;; 'Start At Boot') systemctl enable iptables diff --git a/config/menu b/config/menu index 7d3706b..8b5922a 100644 --- a/config/menu +++ b/config/menu @@ -28,7 +28,7 @@ case $sel in 'Sudoers') menu config/sudoers/menu;; 'Systemd') menu config/systemd/menu;; 'XOrg') menu config/xorg/menu;; - 'Grub') nano /etc/default/grub + 'Grub') editfile /etc/default/grub if(confirm "Run grub-mkconfig -o /boot/grub/grub.cfg ?") then grub-mkconfig -o /boot/grub/grub.cfg fi;; diff --git a/config/sudoers/menu b/config/sudoers/menu index b2a961d..e47e01f 100644 --- a/config/sudoers/menu +++ b/config/sudoers/menu @@ -43,7 +43,7 @@ case $sel in "${sudoerlist[@]}" \ 3>&1 1>&2 2>&3) if [ "$?" = "0" ]; then - nano /etc/sudoers.d/$sel + editfile /etc/sudoers.d/$sel fi ;; 'Delete sudoer') @@ -64,7 +64,7 @@ case $sel in fi ;; 'Edit /etc/sudoers') - nano /etc/sudoers + editfile /etc/sudoers ;; esac diff --git a/config/xorg/menu b/config/xorg/menu index f72e0a8..3a6be82 100644 --- a/config/xorg/menu +++ b/config/xorg/menu @@ -29,10 +29,10 @@ case $sel in echo ' Option "XkbVariant" ""' >> /etc/X11/xorg.conf.d/00-keyboard.conf echo ' Option "XkbOptions" ""' >> /etc/X11/xorg.conf.d/00-keyboard.conf echo 'EndSection' >> /etc/X11/xorg.conf.d/00-keyboard.conf - nano /etc/X11/xorg.conf.d/00-keyboard.conf + editfile /etc/X11/xorg.conf.d/00-keyboard.conf fi ;; - "Edit /etc/X11/xorg.conf.d/00-keyboard.conf") nano /etc/X11/xorg.conf.d/00-keyboard.conf;; + "Edit /etc/X11/xorg.conf.d/00-keyboard.conf") editfile /etc/X11/xorg.conf.d/00-keyboard.conf;; esac exit 0 diff --git a/install/console/generic b/install/console/generic index a7acf01..d5d000b 100644 --- a/install/console/generic +++ b/install/console/generic @@ -9,6 +9,7 @@ options+=("dmidecode" "Hardware infos" on) options+=("dialog" "Dialog boxes for script" on) options+=("nmon" "System monitor" off) options+=("mc" "Dual pane file explorer" off) +options+=("vim" "Vi Improved" off) options+=("powertop" "power mon and management" off) options+=("gpm" "Console mouse support" off) diff --git a/install/system/services/menu b/install/system/services/menu index 3e0403d..3a36953 100644 --- a/install/system/services/menu +++ b/install/system/services/menu @@ -78,14 +78,14 @@ for itm in $sel; do echo "" >> /etc/snmp/snmpd.conf echo "# SNMP 3" >> /etc/snmp/snmpd.conf echo "#rouser read_only_user" >> /etc/snmp/snmpd.conf - nano /etc/snmp/snmpd.conf + editfile /etc/snmp/snmpd.conf fi if (confirm "Create and edit /var/net-snmp/snmpd.conf (for SNMPv3) ?") then mkdir -p /var/net-snmp/ > /dev/null echo "# Note : Clear text password will be encrypted when you restart snmpd." > /var/net-snmp/snmpd.conf echo "" >> /var/net-snmp/snmpd.conf echo "#createUser read_only_user SHA password1 AES password2" >> /var/net-snmp/snmpd.conf - nano /var/net-snmp/snmpd.conf + editfile /var/net-snmp/snmpd.conf fi svcenable snmpd "SNMP Server" ;; diff --git a/updates/menu b/updates/menu index de64e64..210bbc4 100644 --- a/updates/menu +++ b/updates/menu @@ -133,8 +133,8 @@ case $sel in ;; 'Clean orphan') pacman -Rns $(pacman -Qqtd);; 'Clean cache') pacman -Sc;; - 'Edit pacman.conf') nano /etc/pacman.conf;; - 'Edit mirrorlist') nano /etc/pacman.d/mirrorlist;; + 'Edit pacman.conf') editfile /etc/pacman.conf;; + 'Edit mirrorlist') editfile /etc/pacman.d/mirrorlist;; 'Update keyring') pacman -S archlinux-keyring;; 'Refresh pacman keys') pacman-key --refresh-keys;; 'Add GPG key')