net home

Created lundi 08 février 2016

>~ net_home.sh

1 #! /bin/bash
2 ##Le script stop networking
3 ##efface le fichier de conf du proxy
4 ##redemarre network-manager
5 # In case ctrl+c is pressed, restore terminal color and prompt settings, then exit
6 function ctrl_c()
7 {
8 	echo
9 	echo "Exiting script..."
10 	echo
11 	tput sgr0
12 	stty $sttysettings
13 	exit 0
14 }
15 # If no su privileges available, try to get them
16 if  ! "$(whoami)" == "root"  ; then
17 	echo -e "\nordinatous et #!++ "
18 
19 	# No sudo available? Then we can't get su privs. Advise and exit
20 	if  $(which sudo) == ""  ; then
21 		echo "'sudo' package missing! Please install."
22 		echo "e.g.: apt-get install sudo"
23 		exit 1
24 	fi
25 
26 	echo "Requesting su permissions..."
27 	# Run this script with sudo privs
28 	sudo $0 $*
29 		# If running this script with su privs failed, advise to do so manually and exit
30 		if  $? > 0  ; then
31 		echo
32 		echo "Acquiring su permission failed!"
33 		echo "Please run this script with sudo permissions!"
34 		echo "(e.g. 'sudo $0' or 'sudo bash $0')"
35 		echo
36 		exit 1
37 	fi
38 exit 0
39 fi
40 #! /bin/bash
41 showtitle() {
42 clear
43 green="\e[36;5;82m"
44 stdcol="\e[0m"
45 echo -e "\n$green     ###°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°###"
46 echo "   ###   __  ___   __                 ______  __         __   ###"
47 echo " ###    /  \ |  \ |  \  | |\   |   /\   |    /  \  |   ||  |   ###"
48 echo " ###   /    \|  / |   \ | | \  |  /__\  |   /    \ |   | \      ###"
49 echo " ###   \    /|  \ |   / | |  \ | /    \ |   \    / |   |  \     ###"
50 echo " ###    \__/ |   \|__/  | |   \|/      \|    \__/  |___||__\    ###"
51 echo "  ###                                                          ###"
52 echo  "   ###  script basculement configuration                     ###"
53 echo -e "    ###°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°###\n"
54 echo "-> http://ordinatous.com"
55 echo -e "-> http://cv.ordinatous.com\n"
56 }
57 showtitle
58 exit 0
59 # Exit script
60 ctrl_c
61 showtitle
62 mv /etc/apt/apt.conf.d/01proxy /home/utilisateur/backup/01proxy.old
63 /etc/init.d/networking stop
64 /etc/init.d/unbound restart
65 /etc/init.d/network-manager restart
66 exit 0
67 # Exit script
68 ctrl_c

En cas d'echec d'authentification le script exit!

1 ordinatous et #!++ 
2 Requesting su permissions...
3 [sudo] password for xtbushido: 
4 Sorry, try again.
5 [sudo] password for xtbushido: 
6 Sorry, try again.
7 [sudo] password for xtbushido: 
8 Sorry, try again.
9 sudo: 3 incorrect password attempts
10 
11 Acquiring su permission failed!
12 Please run this script with sudo permissions!
13 (e.g. 'sudo /home/xtbushido/bin/net_home.sh' or 'sudo bash /home/xtbushido/bin/net_home.sh')



Backlinks: Home:07) Script shell bash