-
Notifications
You must be signed in to change notification settings - Fork 55
/
startup.sh
47 lines (42 loc) · 1.48 KB
/
startup.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
#!/bin/bash
set -e
if [[ "${STARTUP_DEBUG_MODE:-0}" -eq 1 ]]; then
set -x
fi
# Deactivate license when it exists
deactivate() {
echo "Deactivating license ..."
is_deactivated=0
retries=0
while [[ $is_deactivated -ne 1 ]] && [[ $retries -le 3 ]]; do
/opt/rstudio-connect/bin/license-manager deactivate >/dev/null 2>&1
is_deactivated=1
((retries+=1))
for file in $(ls -A /var/lib/.local); do
if [ -s /var/lib/.local/$file ]; then
if [[ $retries -lt 3 ]]; then
echo "License did not deactivate, retry ${retries}..."
is_deactivated=0
else
echo "Unable to deactivate license. If you encounter issues activating your product in the future, please contact Posit support."
fi
continue
fi
done
done
}
trap deactivate EXIT
# Activate License
RSC_LICENSE_FILE_PATH=${RSC_LICENSE_FILE_PATH:-/etc/rstudio-connect/license.lic}
if ! [ -z "$RSC_LICENSE" ]; then
/opt/rstudio-connect/bin/license-manager activate $RSC_LICENSE
elif ! [ -z "$RSC_LICENSE_SERVER" ]; then
/opt/rstudio-connect/bin/license-manager license-server $RSC_LICENSE_SERVER
elif test -f "$RSC_LICENSE_FILE_PATH"; then
/opt/rstudio-connect/bin/license-manager activate-file $RSC_LICENSE_FILE_PATH
fi
# ensure these cannot be inherited by child processes
unset RSC_LICENSE
unset RSC_LICENSE_SERVER
# Start RStudio Connect
/opt/rstudio-connect/bin/connect --config /etc/rstudio-connect/rstudio-connect.gcfg