Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
scripts
File Content:
addip.sh
#!/bin/bash restart_network() { if [ -f /etc/centos-release ]; then OSNAME="CentOs" OSVERSION_FULL=$(sed 's/^.*release //;s/ (Fin.*$//' /etc/centos-release) VERSION=${OSVERSION_FULL:0:1} # return 6 or 7 if [ $VERSION -eq 8 ]; then systemctl restart NetworkManager.service /usr/bin/nmcli networking off /usr/bin/nmcli networking on else service network restart >>$null_path; fi fi } IPprefix_by_netmask() { #function returns prefix for given netmask in arg1 ipcalc -p 1.1.1.1 $1 | sed -n 's/^PREFIX=\(.*\)/\/\1/p' } null_path="/dev/null"; if [ "$#" -lt 2 ]; then echo ""; else method_detail=$1; case $method_detail in addip) IP=$2 ALREADY=$(grep "IPADDR=$IP" -Rl /etc/sysconfig/network-scripts/ifcfg-*) if [ ! -z $ALREADY ] then echo "ALREADY IP ADDED $ALREADY";exit; fi enth=$(ip route | grep -v default | head -n 1 | awk '{ print $3 }') if [ -z $enth ] then enth=$3 fi orginal_net_file="/etc/sysconfig/network-scripts/ifcfg-$enth" sed -i "s/^HWADDR=/#HWADDR=/g" $orginal_net_file IPADDR=$(cat $orginal_net_file | grep "^IPADDR=" | awk -F"=" '{ print $2 }') echo "orginal_net_file $orginal_net_file" if [ -f $orginal_net_file ] then i=0 while true do adaterFile=$orginal_net_file:$i if [ ! -f $adaterFile ] then break; fi i=`expr $i + 1` done cp -pr $orginal_net_file $adaterFile sed -i "s/NAME=$enth/NAME=$enth:$i/g" $adaterFile sed -i "s/DEVICE=$enth/DEVICE=$enth:$i/g" $adaterFile sed -i "s/IPADDR=$IPADDR/IPADDR=$IP/g" $adaterFile fi ifup $adaterFile restart_network echo "1"; ;; remvip) IP=$2 orginal_net_dir="/etc/sysconfig/network-scripts/ifcfg-*" adaterFile=$(grep "IPADDR=$IP" -l /etc/sysconfig/network-scripts/ifcfg-*) grep "IPADDR=$IP" -l /etc/sysconfig/network-scripts/ifcfg-* | while read adaterFile do if [ -f $adaterFile ] then IPADDR=$(grep "IPADDR=" $adaterFile | awk -F"=" '{ print $2 }' | tr -d "\n") ADAPTER=$(echo $adaterFile | awk -F"/" '{ print $NF }' | sed 's/ifcfg-//g') NETMASK=$(grep "NETMASK=" $adaterFile | awk -F"=" '{ print $2 }' | tr -d "\n") CIDR=$(IPprefix_by_netmask $NETMASK) rm -f $adaterFile ifdown $ADAPTER ip addr del $IPADDR$CIDR dev $ADAPTER restart_network fi done ;; *) echo ""; ;; esac fi
Edit
Download
Unzip
Chmod
Delete