File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 6
6
SERVICE_NAME=" unitybot"
7
7
SCRIPT_DIR=" $( dirname " $( realpath " $0 " ) " ) "
8
8
9
+ if [ " $( id -u) " -eq 0 ]; then
10
+ SUDO=" "
11
+ else
12
+ SUDO=" sudo"
13
+ fi
14
+
15
+ if ! command -v systemctl > /dev/null; then
16
+ echo " systemctl not found. This installer requires systemd." >&2
17
+ exit 1
18
+ fi
19
+ if [ ! -d /run/systemd/system ]; then
20
+ echo " systemd is not running. Cannot install service." >&2
21
+ exit 1
22
+ fi
23
+
9
24
VENV_PYTHON=" ${SCRIPT_DIR} /.venv/bin/python"
10
25
if [ ! -x " $VENV_PYTHON " ]; then
11
26
echo " Virtual environment not found. Run setup.sh before installing the service." >&2
12
27
exit 1
13
28
fi
14
29
15
- cat << EOF | sudo tee /etc/systemd/system/${SERVICE_NAME} .service >/dev/null
30
+ cat << EOF | $SUDO tee /etc/systemd/system/${SERVICE_NAME} .service >/dev/null
16
31
[Unit]
17
32
Description=UnityBot Discord Bot
18
33
After=network.target
@@ -29,9 +44,9 @@ Restart=on-failure
29
44
WantedBy=multi-user.target
30
45
EOF
31
46
32
- sudo systemctl daemon-reload
33
- sudo systemctl enable ${SERVICE_NAME}
34
- sudo systemctl start ${SERVICE_NAME}
47
+ $SUDO systemctl daemon-reload
48
+ $SUDO systemctl enable ${SERVICE_NAME}
49
+ $SUDO systemctl start ${SERVICE_NAME}
35
50
36
51
echo " Service ${SERVICE_NAME} installed and started."
37
52
Original file line number Diff line number Diff line change @@ -66,9 +66,9 @@ source .venv/bin/activate
66
66
prompt_var () {
67
67
local var_name=$1
68
68
local env_val
69
- env_val=$( printenv " $var_name " )
69
+ env_val=$( printenv " $var_name " 2> /dev/null || true )
70
70
local file_val=" "
71
- [[ -f .env ]] && file_val=$( grep -E " ^${var_name} =" .env | cut -d' =' -f2-)
71
+ [[ -f .env ]] && file_val=$( grep -E " ^${var_name} =" .env | cut -d' =' -f2- 2> /dev/null || true )
72
72
73
73
if [[ " $TARGET " == " env" ]]; then
74
74
if [[ -n " $file_val " ]]; then
You can’t perform that action at this time.
0 commit comments