Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- configurePath=/etc/network/interfaces
- interface="$1"
- ip="$2"
- mask="$3"
- gateway="$4"
- dns="$5"
- testPermission(){
- if [ $(id -u) -ne 0 ]; then
- echo "You need root access\n"
- exit 1
- fi
- }
- clearFile(){
- if [ -f "$configurePath" ]; then
- sudo rm "$configurePath"
- fi
- }
- stringInterface(){
- local stringInterface="auto $interface\n"
- stringInterface+="iface $interface inet static\n"
- stringInterface+=" address $ip\n"
- stringInterface+=" netmask $mask\n"
- stringInterface+=" gateway $gateway\n"
- stringInterface+=" dns-nameservers $dns\n"
- echo "$stringInterface"
- }
- createInterface(){
- sudo echo -e "$(stringInterface)" | sudo tee "$configurePath"
- }
- testInterface(){
- sudo /etc/init.d/networking restart
- }
- testPermission
- createInterface
- testInterface
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement