-
-
Notifications
You must be signed in to change notification settings - Fork 304
/
Copy path1.53.0.sh
65 lines (58 loc) · 1.4 KB
/
1.53.0.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
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
#!/usr/bin/env bash
[[ -f /usr/local/etc/instance.cfg ]] || {
cohorte_id=$((RANDOM % 100))
cat > /usr/local/etc/instance.cfg <<EOF
{
"cohorteId": ${cohorte_id}
}
EOF
}
cat > /home/www/ncp-app-bridge.sh <<'EOF'
#!/bin/bash
set -e
grep -q '[\\&#;`|*?~<>^()[{}$&]' <<< "$*" && exit 1
action="${1?}"
[[ "$action" == "config" ]] && {
config_type="${2?}"
arg="${3}"
[[ -z "$arg" ]] || {
key="${arg%=*}"
val="${arg#*=}"
}
if [[ "$config_type" == "ncp" ]]
then
config_path="/usr/local/etc/ncp.cfg"
elif [[ "$config_type" == "ncp-community" ]]
then
. /usr/local/etc/library.sh
[[ -z "${key}" ]] || {
set_app_param ncp-community.sh "${key}" "${val}"
}
get_app_params ncp-community.sh
exit $?
else
echo "ERROR: Invalid config name '${config_type}'" >&2
exit 1
fi
[[ -z "${key}" ]] || {
cfg="$(jq ".${key} = \"${val}\"" <"$config_path")"
echo "$cfg" > "$config_path"
}
cat "$config_path"
exit 0
}
[[ "$action" == "file" ]] && {
file="${2?}"
if [[ "$file" == "ncp-version" ]]
then
cat /usr/local/etc/ncp-version
else
echo "ERROR: Invalid file '${file}'" >&2
exit 1
fi
exit 0
}
EOF
chmod 700 /home/www/ncp-app-bridge.sh
sed -i 's|www-data ALL = NOPASSWD: .*|www-data ALL = NOPASSWD: /home/www/ncp-launcher.sh , /home/www/ncp-backup-launcher.sh, /home/www/ncp-app-bridge.sh, /sbin/halt, /sbin/reboot|' /etc/sudoers
ncc upgrade