blob: dc8b5aabab69fa9f74aa93d2f855f437efea04b5 (
plain)
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
|
#!/bin/sh
ardor_user='ardor'
ardor_home='/opt/ardor'
ardor_log_path='/var/log/ardor'
ardor_db_path='/var/lib/ardor'
ardor_old_db_path='/opt/ardor/nxt_db'
ardor_conf_dir='/opt/ardor/conf'
ardor_pid_dir='/opt/ardor/.ardor'
move_existing_ardor_db() {
set -e
if [ -e "$ardor_old_db_path" ] && [ "$(stat -c %F "$ardor_old_db_path")" = 'directory' ]; then
mv -T "$ardor_old_db_path" "$ardor_db_path"
fi
}
correct_ardor_ownerships() {
set -e
touch "$ardor_conf_dir/.lock"
chown -R "$ardor_user":"$(id -gn "$ardor_user")" \
"$ardor_log_path" \
"$ardor_db_path" \
"$ardor_conf_dir/data" \
"$ardor_conf_dir/.lock" \
"$ardor_pid_dir"
chgrp "$(id -gn "$ardor_user")" \
"$ardor_conf_dir/nxt-default.properties"
}
ensure_ardor_user() {
set -e
if ! id "$ardor_user" > /dev/null 2>&1; then
useradd -rd "$ardor_home" -s '/bin/false' "$ardor_user"
else
usermod -d "$ardor_home" -s '/bin/false' "$ardor_user" > /dev/null
fi
}
pre_install() {
set -e
move_existing_ardor_db
}
post_install() {
set -e
ensure_ardor_user
correct_ardor_ownerships
}
post_upgrade() {
set -e
ensure_ardor_user
correct_ardor_ownerships
}
# vim: set ts=2 sw=2 et syn=sh:
|