-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnsh-update-check.sh
More file actions
executable file
·217 lines (152 loc) · 3.36 KB
/
Copy pathnsh-update-check.sh
File metadata and controls
executable file
·217 lines (152 loc) · 3.36 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
############################################################################
# Copyright Nash!Com, Daniel Nashed 2023-2025 - APACHE 2.0 see LICENSE
############################################################################
# Domino on Linux project update script
# Version 4.0.9 06.12.2025
SCRIPT_NAME=$(readlink -f $0)
SCRIPT_DIR=$(dirname $SCRIPT_NAME)
print_delim()
{
echo "--------------------------------------------------------------------------------"
}
log_ok ()
{
echo
echo "$1"
echo
}
log_error()
{
echo
echo "$1"
echo
}
header()
{
echo
print_delim
echo "$1"
print_delim
echo
}
# Check if sudo is requested or fall back in case of error
SUDO()
{
local RET=
if [ "$EUID" = 0 ]; then
"$@"
return 0
fi
if [ -z "$DOMINO_NO_SUDO" ]; then
sudo "$@"
RET="$?"
if [ "$RET" = "0" ]; then
return 0
fi
if [ "$RET" = "9" ]; then
return 0
fi
echo
echo "Info: export DOMINO_NO_SUDO=1 or enable sudo $DOMINO_USER for systemctl"
echo
fi
"$@"
}
git_update_repo()
{
local REPO_DIR="$1"
local CURRENT_UID="$(id -u)"
local OWNER_UID=
if [ -z "$REPO_DIR" ]; then
return 0
fi
if [ ! -e "$REPO_DIR" ]; then
return 0
fi
OWNER_UID="$(stat -c %u "$REPO_DIR")"
cd "$REPO_DIR"
if [ "$OWNER_UID" = "$CURRENT_UID" ]; then
git pull
elif [ "$OWNER_UID" = "0" ]; then
SUDO git pull
else
log_error "Please pull repository with the correct owner: $REPO_DIR"
sleep 5
return 1
fi
local rc=$?
if [ $rc -ne 0 ]; then
log_error "Git repo update failed: $REPO_DIR"
sleep 5
fi
log_ok "Git repo pulled: $REPO_DIR"
}
update_github_repos()
{
local REPO_DIR=
header "Updating GitHub projects"
git_update_repo /local/github/domino-container
git_update_repo /local/github/domino-startscript
}
update_components()
{
if [ ! -e /local/github/domino-startscript ]; then
log_error "Start Script GitHub repository not found"
return 0
fi
cd /local/github/domino-startscript
if [ -n "$(which domino 2>/dev/null)" ]; then
header "Updating Domino Start Script"
./install_script --check-version
if [ "$?" = "0" ]; then
log_ok "Latest Domino Start Script already installed"
else
SUDO ./install_script
fi
fi
if [ -n "$(which dominoctl 2>/dev/null)" ]; then
header "Updating Domino Container Control (dominoctl)"
./install_dominoctl --check-version
if [ "$?" = "0" ]; then
log_ok "Latest Domino Container Control (dominoctl) already installed"
else
SUDO ./install_dominoctl
fi
fi
if [ -n "$(which domdownload 2>/dev/null)" ]; then
header "Updating Domino Download Script (domdownload)"
./domdownload.sh --check-version
if [ "$?" = "0" ]; then
log_ok "Latest Domino Download Script (domdownload) already installed"
else
SUDO ./domdownload.sh install
fi
fi
}
process_updates()
{
local ONLY_UPDATE_REPOS=
for a in "$@"; do
p=$(echo "$a" | awk '{print tolower($0)}')
case "$p" in
repo)
ONLY_UPDATE_REPOS=1
;;
*)
log_error "Invalid parameter [$a]"
sleep 5
return 1
;;
esac
done
update_github_repos
if [ "$ONLY_UPDATE_REPOS" = "1" ]; then
return 0
fi
update_components
}
# --- Main logic ---
SAVED_DIR=$(pwd)
process_updates
cd $SAVED_DIR