Repository navigation
Expand file tree
/
Copy pathintegrate
More file actions
executable file
·162 lines (131 loc) · 2.17 KB
/
Copy pathintegrate
File metadata and controls
executable file
·162 lines (131 loc) · 2.17 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
# constants
declare -r INVOKED_DIR="$PWD"
declare -r SCRIPT_ROOT=$(cd "${0%/*}" && echo "$PWD")
# print the command and execute it
echo_exec() {
echo "$@"
"$@"
}
confirm_install_dir() {(
status=0
error=""
finish() {
if test $status -eq 0; then
echo "OK"
return $status
else
echo "FAIL"
echo $error
return $status
fi
}
fail() {
error="anomaly detected in install directory"
status=1
}
echo -n "checking if the script was run correctly... "
test -d "./builds" || fail
test -d "./pkg" || fail
test -d "./src" || fail
test -x "./integrate" || fail
test -x "./launcher" || fail
finish
)}
prepare_users() {(
status=0
error=""
finish() {
if test $status -eq 0; then
echo "OK"
return $status
else
echo "FAIL"
echo $error
return $status
fi
}
fail() {
error="couldn't create users/groups"
status=1
}
echo -n "making sure appropriate users/groups exist... "
if id "ntofto-web" >/dev/null 2>&1;then :; else
echo
echo -n '> '
echo_exec useradd \
-c "NTOFTO Web Package" \
-d "${SCRIPT_ROOT}" \
-p '*' \
-Mr "ntofto-web" || fail
echo -n '... '
fi
finish
)}
set_dir_own() {
status=0
error=""
finish() {
if test $status -eq 0; then
echo "OK"
return $status
else
echo "FAIL"
echo $error
return $status
fi
}
fail() {
error="couldn't claim directory ownership"
status=1
}
echo -n "setting directory ownership... "
echo
echo -n '> '
echo_exec chown -R "ntofto-web:ntofto-web" "${SCRIPT_ROOT}" || fail
echo -n '... '
finish
}
set_dir_mod() {
status=0
error=""
finish() {
if test $status -eq 0; then
echo "OK"
return $status
else
echo "FAIL"
echo $error
return $status
fi
}
fail() {
error="couldn't set directory modes"
status=1
}
echo -n "setting directory modes... "
echo
echo -n '> '
echo_exec chmod 02770 "${SCRIPT_ROOT}" || fail
echo -n '... '
finish
}
main() {
cd "$SCRIPT_ROOT"
if test ${UID} -ne 0; then
echo "!!! this script must be run as root"
fi
fail() {
echo
echo "Aborting"
exit 1
}
confirm_install_dir || fail
echo
prepare_users || fail
echo
set_dir_own || fail
echo
set_dir_mod || fail
}
main