-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
144 lines (104 loc) · 2.96 KB
/
init.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
## Some init stuff
## first, variables that can be, but dont have to be custom
## some formatted date
NOW=$(date +%Y.%m.%d-%H:%M:%S)
MSG="## srvctl $NOW"
## Servers can have a direct domain name - what we can override
## useful in multi-server setups
DDN=$(dnsdomainname)
SDN=$(dnsdomainname)
## MYSQL / MARIADB conf file that stores the mysql root password - in containers
MDF=/etc/mysqldump.conf
## global variables with default values
all_arg_set=false
## get $VERSION_ID
source /etc/os-release
ARCH=$(uname -m)
SRVCTL_HOSTS=''
if [ -f /etc/srvctl/hosts ]
then
while read _h
do
if [ "$_h" == "$HOSTNAME" ] || [ "$_h" == localhost ] || [ "$HOSTNAME" == localhost ]
then
continue
fi
SRVCTL_HOSTS="$_h $SRVCTL_HOSTS"
done < /etc/srvctl/hosts
fi
## defaults that can stay as tey are
## .. or can be customized, ...
DISABLE_NFS=false
DISABLE_BINDMOUNT=false
LOGO_SVG=$install_dir/d250.svg
LOGO_ICO=$install_dir/favicon.ico
## set FEDORA to the corresponding fedora version on this computer
if ! [ "$NAME" == "Fedora" ]
then
## Something is wrong. This is not even fedora. We just run the client then, ...
## TODO check how this should be with CentOS and other distros.
source $install_dir/srvctl-client.sh $1
fi
####################################################
## The main /srv folder mount point - SSD recommended
SRV=/srv
## These where the variables to be custimized - used in update-install too!
source $install_dir/hs-install/config
##########################################################
## Import custom configuration directives now, to apply customized variables.
if [ -f "/etc/srvctl/config" ]
then
source /etc/srvctl/config
#if [ -z "$HOSTIPv4" ]
#then
# HOSTIPv4=$(dig @ns1.google.com -t txt o-o.myaddr.l.google.com +short)
# ntc "HOSTIPv4 is $HOSTIPv4"
# echo "## srvctl-detected $NOW" >> /etc/srvctl/config
# echo "HOSTIPv4=$HOSTIPv4" >> /etc/srvctl/config
# echo '' >> /etc/srvctl/config
#fi
fi
mkdir -p $LOG
## variable detection
onHS=false
onVE=false
isUSER=false
isROOT=false
isSUDO=false
LXC_SERVER=false
SC_USER="$(whoami)"
if [ -f "/var/srvctl/locale-archive" ]
then
LXC_SERVER=true
## Some way to figure out, .. is this script running in the srvctl container, or on the host system?
if mount | grep -q 'on /var/srvctl type'
then
## We are in a container of srvctl for sure
#echo CONTAINER $(hostname)
onHS=false
onVE=true
else
## We are propably on the host
#echo HOST $(hostname)
onHS=true
onVE=false
fi
fi
## we use the format srvctl or sc command argument [plus-argument]
## command, lowercase
CMD=$1
CMD=${CMD,,}
## argument
ARG=$2
## optional single argument
OPA=$3
## all optional arguments
OPAS="${@:2}"
OPAS3="${@:3}"
OPAS4="${@:4}"
## all arguments, including command and argument
ARGS="$*"
## Current start directory
CWD=$(pwd)
cd ~