Created
November 13, 2013 03:54
-
-
Save juanvgarcia/7443442 to your computer and use it in GitHub Desktop.
Revisions
-
juanvgarcia created this gist
Nov 13, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/bin/sh if [ "$1" != "work" ] && [ "$1" != "home" ]; then echo "Wrong arguments Usage: $0 home|work" exit $E_BADARGS fi interface_file='/etc/network/interfaces' work_config_start=`grep -n "#work config start" $interface_file | awk -F':' '{print $1}'` work_config_end=`grep -n "#work config end" $interface_file | awk -F':' '{print $1}'` home_config_start=`grep -n "#home config start" $interface_file | awk -F':' '{print $1}'` home_config_end=`grep -n "#home config end" $interface_file | awk -F':' '{print $1}'` if [ "$1" = "work" ]; then start_to_comment=`expr $home_config_start + 1` end_to_comment=`expr $home_config_end - 1` start_to_uncomment=`expr $work_config_start + 1` end_to_uncomment=`expr $work_config_end - 1` else start_to_comment=`expr $work_config_start + 1` end_to_comment=`expr $work_config_end - 1` start_to_uncomment=`expr $home_config_start + 1` end_to_uncomment=`expr $home_config_end - 1` fi sed -i.bak "$start_to_comment,$end_to_comment s/^/#/g" $interface_file sed -i.bak "$start_to_uncomment,$end_to_uncomment s/^#//g" $interface_file service networking restart