-
Notifications
You must be signed in to change notification settings - Fork 0
/
srvctl-sudo.sh
executable file
·72 lines (55 loc) · 1.02 KB
/
srvctl-sudo.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
67
68
69
70
#!/bin/bash
## Special srvctl for sudo use only.
if [ "$UID" -ne "0" ]
then
echo "ERROR. nonroot sudoer."
exit
fi
## limited init
isROOT=true
install_bin=$(realpath "$BASH_SOURCE")
install_dir=${install_bin:0:-15}
source $install_dir/init.sh
isROOT=true
isSUDO=true
## silent log entry
echo "$NOW : [$SUDO_USER@$(hostname) $(pwd)]# $0 $@" >> $LOG/sudo.log
## some extra checks
if ! $LXC_SERVER
then
echo "ERROR. Not an LXC server."
exit
fi
if ! $onHS
then
echo "ERROR. Not on serverfarm host."
exit
fi
if $onVE
then
echo "ERROR. This is not supported on containers."
exit
fi
##
## obsolete
SC_SUDO_USER=$SUDO_USER
#the real thing
SC_USER=$SUDO_USER
## init libs
source $install_dir/libs/commonlib.sh
load_libs
## disabled functions
function hint {
echo "-" >> /dev/null
}
function ok {
echo "-" >> /dev/null
}
function man {
echo "-" >> /dev/null
}
SUCC=" "
## execute the commands
load_commands
## return to the directory we started from.
cd $CWD >> /dev/null 2> /dev/null