forked from LandmakTechnology/scripting
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vital_user_switch_function.sh
66 lines (65 loc) · 1.37 KB
/
vital_user_switch_function.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# switch case 1
echo "Switch case demo starts.."
case $1 in
start) echo "starting sq server.."
echo "started..."
;;
stop)
echo "stopping the server"
echo "server stopped";;
restart)
echo "restarting the server"
echo "server restarted"
;;
*)
echo "You have to pass start|stop|restart"
;;
esac
echo "Switch case is over"
_________________________________________________________
# switch case 2
echo "Please enter the number 1 to 5 only"
read num
case $num in
1)
echo "you have type one in the correct number range"
;;
2)
echo "you have type two in the correct number range"
;;
3)
echo "you have type 3 in the correct number range"
;;
*)
echo "you have to type 1 to 5"
echo "you have type an invalid number range"
;;
esac
echo "done"
___________________
# Functions
devfn()
{
echo "FelloW Engineers"
echo "DevOps is above the middle class"
echo "Welcome to a new era"
}
source ./fn1.sh
devfn
______________________________________
# Script to adduser
# Author Landmark Technology
# This script will create a user account
# You need to be root or have sudo access to execute
echo -n "Enter the username: "
read username
echo -n "Enter the password: "
read -s password
adduser "$username"
echo "$password" | passwd "$username" --stdin
<<ST
--stdin
This option is used to indicate that passwd should read the new
password from standard input, which can be a pipe.
cat /etc/passwd to verify
ST