Created
April 21, 2021 19:57
-
-
Save almuhdilkarim/e825e0f9e151b712c294c8c75ac1a78c to your computer and use it in GitHub Desktop.
netpid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # Aplikasi untuk aktivasi network daemon dan network pheripheral | |
| # Depend | |
| # 1. iwd | |
| # 2. iptables | |
| ##=============================================== | |
| ## Function systemd network module | |
| ##=============================================== | |
| function sysup_cockpit() { | |
| systemctl start systemd-netowrkd.socket &> /dev/null; | |
| systemctl start systemd-networkd &> /dev/null; | |
| systemctl start systemd-resolved &> /dev/null; | |
| systemctl start iptables &> /dev/null; | |
| systemctl start iwd &> /dev/null; | |
| } | |
| function sysdw_cockpit() { | |
| systemctl stop iptables &> /dev/null; | |
| systemctl stop iwd &> /dev/null ; | |
| systemctl stop systemd-resolved &> /dev/null; | |
| systemctl stop systemd-networkd.socket &> /dev/null ; | |
| systemctl stop systemd-networkd &> /dev/null ; | |
| } | |
| function sys_upg() { | |
| echo "Do you want to upgrade system?"; | |
| read -p "Type (Y) to uprade or type (n) to abort : " upgrade; | |
| if [ $upgrade == 'Y' ]; then | |
| pacman -Syu; | |
| echo "---------------------------------------------------------"; | |
| echo " Progres Status :" | |
| echo " Main System [ Upgraded ]"; | |
| echo "---------------------------------------------------------"; | |
| fi | |
| } | |
| ##=============================================== | |
| ## Banner | |
| ##=============================================== | |
| function credit() { | |
| echo "=========================================================" | |
| echo " __ __ ______ ______ ______ __ ______ " | |
| echo "/\ -.\ \ /\ ___\ /\__ _\ /\ == \ /\ \ /\__ _\ " | |
| echo "\ \ \-. \ \ \ __\ \/_/\ \/ \ \ _-/ \ \ \ \/_/\ \/ " | |
| echo " \ \_\\ \_ \ \ \_____\ \ \_\ \ \_\ \ \_\ \ \_\ " | |
| echo " \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/ \/_/ " | |
| echo " " | |
| echo " Author : Al Muhdil Karim" | |
| echo " Version : Alpha 1.0 " | |
| echo " Program : Network Daemon and Service " | |
| echo "=========================================================" | |
| } | |
| function appstatus() { | |
| echo " DAEMON STATUS" | |
| systemdnt=$( systemctl status systemd-networkd | grep "dead"); | |
| systemdrs=$( systemctl status systemd-networkd | grep "dead" ); | |
| systemdfw=$( systemctl status iptables | grep "dead" ); | |
| if [[ $systemdnt > 1 ]]; then | |
| ntres="Network : Died | " | |
| else | |
| ntres="Network : Active | " | |
| fi | |
| if [[ $systemdrs > 1 ]]; then | |
| rsres=" Resolved : Died | " | |
| else | |
| rsres=" Resolved : Active | " | |
| fi | |
| if [[ $systemdfw > 1 ]]; then | |
| fwres=" Firewall : Died" | |
| else | |
| fwres=" Firewall : Active " | |
| fi | |
| echo " "$ntres$rsres$fwres; | |
| echo "---------------------------------------------------------" | |
| } | |
| function appopt() { | |
| echo " Select Network Action by type number bellow"; | |
| echo " 1. Enable Network"; | |
| echo " 2. Disable Network"; | |
| echo " 3. Exit"; | |
| echo " ---------------------------------------------------------"; | |
| } | |
| function banner() { | |
| clear; | |
| credit ; | |
| appstatus ; | |
| appopt ; | |
| } | |
| function main() { | |
| banner; | |
| read -p "Type your action number : " device; | |
| while : | |
| do | |
| case $device in | |
| '1') | |
| echo "Activating module ..." | |
| sysup_cockpit; | |
| sleep 1; | |
| sys_upg; | |
| main ;; | |
| '2') | |
| echo "deactivating module ..." | |
| sysdw_cockpit; | |
| sleep 1; | |
| main;; | |
| '3') | |
| clear; | |
| exit ;; | |
| *) | |
| main;; | |
| esac | |
| done | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment