Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
telemersion
Telemersive Switchboard
Commits
39a352c4
Commit
39a352c4
authored
Feb 12, 2021
by
Roman Haefeli
Browse files
add script to set up tpf-switchboard as a service
parent
61d5e19a
Changes
1
Hide whitespace changes
Inline
Side-by-side
setup.sh
0 → 100755
View file @
39a352c4
#!/bin/bash
USER
=
"tpf-switchboard"
APP_PATH
=
"
$(
cd
"
$(
dirname
"
$0
"
)
"
>
/dev/null 2>&1
;
pwd
-P
)
"
APP_NAME
=
"switchboard"
SERVICE_NAME
=
"tpf-switchboard"
LISTEN_PORT
=
3591
LISTEN_ADDRESS
=
"0.0.0.0"
# are we root?
if
[
"
$(
whoami
)
"
!=
"root"
]
then
echo
"We are not running as root. Exiting now."
exit
1
fi
# Install flask
if
!
which flask
>
/dev/null
then
apt-get
install
python3-flask
||
exit
1
fi
# Install gunicorn3
if
!
which gunicorn3
>
/dev/null
then
apt-get
install
gunicorn3
||
exit
1
fi
# add user to the system
if
!
id
-u
"
$USER
"
>
/dev/null 2>&1
then
useradd
-r
-s
/usr/sbin/nologin
$USER
||
exit
1
fi
SYSTEMD_UNIT_CONTENT
=
"
[Unit]
Description=tpf-switchboard - manager for udp proxies
After=syslog.target
[Service]
Type=simple
ExecStart=/usr/bin/gunicorn3
\\
--bind
$LISTEN_ADDRESS
:
$LISTEN_PORT
\\
--chdir
$APP_PATH
\\
$APP_NAME
:app
User=
$USER
Group=
$USER
[Install]
WantedBy=multi-user.target
"
echo
"
$SYSTEMD_UNIT_CONTENT
"
>
/etc/systemd/system/
${
SERVICE_NAME
}
.service
systemctl daemon-reload
systemctl
enable
${
SERVICE_NAME
}
.service
systemctl start
${
SERVICE_NAME
}
.service
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment