forked from nextcloud/vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_lib.sh
37 lines (33 loc) · 1.16 KB
/
fetch_lib.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
#!/bin/bash
# shellcheck disable=2034,2059
true
# see https://github.com/koalaman/shellcheck/wiki/Directive
IRed='\e[0;91m' # Red
IGreen='\e[0;92m' # Green
ICyan='\e[0;96m' # Cyan
Color_Off='\e[0m' # Text Reset
print_text_in_color() {
printf "%b%s%b\n" "$1" "$2" "$Color_Off"
}
if [[ "$EUID" -ne 0 ]]
then
print_text_in_color "$IRed" "You must run fetch_lib with sudo privileges, or directly as root!"
print_text_in_color "$ICyan" "Please report this to https://github.com/nextcloud/vm/issues if you think it's a bug."
exit 1
fi
mkdir -p /var/scripts
if ! [ -f /var/scripts/lib.sh ]
then
if ! curl -sfL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh -o /var/scripts/lib.sh
then
print_text_in_color "$IRed" "You don't seem to have an internet \
connection and the local lib isn't available. Hence you cannot run this script."
exit 1
fi
elif ! [ -f /var/scripts/nextcloud-startup-script.sh ]
then
print_text_in_color "$ICyan" "Updating lib..."
curl -sfL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh -o /var/scripts/lib.sh
fi
# shellcheck source=lib.sh
source /var/scripts/lib.sh