-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·125 lines (103 loc) · 5.09 KB
/
bootstrap
File metadata and controls
executable file
·125 lines (103 loc) · 5.09 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
#!/bin/bash
_main_(){
# ----------------------------------------------------------------------------
#grep -q '^Ubuntu 16.04' /etc/issue 2> /dev/null || { >&2 echo 'Error: This is neither Ubuntu 16.04 nor 18.04'; exit 1; }
if $(grep -q '^Ubuntu 14.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u14.py'
elif $(grep -q '^Ubuntu 16.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u16.py'
elif $(grep -q '^Ubuntu 18.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u18.py'
elif $(grep -q '^Ubuntu 20.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u20.py'
elif $(grep -q '^Ubuntu 21.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u21.py'
elif $(grep -q '^Ubuntu 22.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u22.py'
elif $(grep -q '^Ubuntu 24.04' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_u24.py'
elif $(grep -q '^Welcome to openSUSE Tumbleweed' /etc/issue 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_suseT.py'
elif $(grep -q '^CentOS Linux release 7' /etc/centos-release 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_cOS7or8_aml8.py'
elif $(grep -q '^CentOS Linux release 8' /etc/centos-release 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_cOS7or8_aml8.py'
elif $(grep -q '^AlmaLinux release 8' /etc/almalinux-release 2> /dev/null) ; then
UPDATE_PY='_update_settings_on_this_machine_cOS7or8_aml8.py'
else
>&2 echo 'Error: OS/Distribution not supported. Supported OS:'
>&2 echo ' Ubuntu 14.04'
>&2 echo ' Ubuntu 16.04'
>&2 echo ' Ubuntu 18.04'
>&2 echo ' Ubuntu 20.04'
>&2 echo ' Ubuntu 21.04'
>&2 echo ' Ubuntu 22.04'
>&2 echo ' Ubuntu 24.04'
>&2 echo ' openSUSE Tumbleweed'
>&2 echo ' CentOS Linux release 7'
>&2 echo ' CentOS Linux release 8'
>&2 echo ' AlmaLinux release 8'
exit 1
fi
test "$( id -u )" = 0 || { >&2 echo 'Error: You are not root, please use "sudo" to run the script'; exit 1; }
#command -v sshd > /dev/null || { >&2 echo 'Error: The package "openssh-server" is not installed'; exit 1; }
command -v sshd || { >&2 echo 'Error: The package "openssh-server" is not installed'; exit 1; }
command -v git > /dev/null || { >&2 echo 'Error: The package "git" is not installed'; exit 1; }
# ----------------------------------------------------------------------------
ORIG_DIR=$PWD
TEMP_DIR=$( mktemp -d )
test -n "$TEMP_DIR" && cd "$TEMP_DIR" || { >&2 echo 'Error: Failed to enter a temporary directory'; exit 1; }
_clean_up_tmp_files () { echo 'Deleting temporary files...'; cd "$ORIG_DIR"; rm -rf "$TEMP_DIR"; echo 'Deleting temporary files... DONE'; }
trap _clean_up_tmp_files EXIT
# ----------------------------------------------------------------------------
cd "$TEMP_DIR"
echo 'Downloading the latest snapshot from the GitHub git repository...'
git clone --quiet --depth 1 https://github.com/fast-crypto-lab/cluster
echo 'Downloading the latest snapshot from the GitHub git repository... DONE'
# ----------------------------------------------------------------------------
cd "$TEMP_DIR/cluster"
# ----------------------------------------------------------------------------
echo 'Trying to acquire a lock...'
if bash -c "./${UPDATE_PY} lock"
then
echo 'Trying to acquire a lock... DONE'
else
>&2 echo 'Error: Failed to acquire a lock, the file /fcl-cluster-maintenance.lock already exists'
exit 2
fi
# ----------------------------------------------------------------------------
echo 'Checking whether this host is already listed in fcl.json...'
if bash -c "./${UPDATE_PY} check-this-host-in-json"
then
echo 'Checking whether this host is already listed in fcl.json... DONE'
else
>&2 echo 'Error: the command `./_update_settings_on_this_machine.py check-this-host-in-json` failed'
bash -c "./${UPDATE_PY} unlock"
exit 3
fi
# ----------------------------------------------------------------------------
echo 'Checking whether fcl.json is applicable for this host...'
if bash -c "./${UPDATE_PY} check-json-applicability"
then
echo 'Checking whether fcl.json is applicable for this host... DONE'
else
>&2 echo 'Error: the command `./_update_settings_on_this_machine.py check-json-applicability` failed'
bash -c "./${UPDATE_PY} unlock"
exit 4
fi
# ----------------------------------------------------------------------------
echo 'Applying fcl.json to this host...'
if bash -c "./${UPDATE_PY} apply-json"
then
echo 'Applying fcl.json to this host... DONE'
else
>&2 echo 'Error: the command `./_update_settings_on_this_machine.py apply-json` failed'
bash -c "./${UPDATE_PY} unlock"
exit 5
fi
# ----------------------------------------------------------------------------
echo 'Releasing the lock...'
bash -c "./${UPDATE_PY} unlock"
echo 'Releasing the lock... DONE'
# ----------------------------------------------------------------------------
};_main_