[experimental] add peerjs service
This commit is contained in:
parent
da77267896
commit
9a4c34a76e
30
functions.sh
Normal file
30
functions.sh
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPTNAME="$( basename -- "$0" )"
|
||||
|
||||
ensure_root () {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_not_root () {
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "This script must not be run as root"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_pwd_is_scriptdir () {
|
||||
if [[ $PWD != $ABSDIR ]]; then
|
||||
echo "Please cd in the script directory before running it :"
|
||||
echo "cd ${ABSDIR}"
|
||||
echo "./${SCRIPTNAME}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_systemd_as_user_dir_exists () {
|
||||
mkdir -p ${HOME}/.config/systemd/user/
|
||||
}
|
16
podman-peerjs/10_install.sh
Executable file
16
podman-peerjs/10_install.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||||
source ${ABSDIR}/../functions.sh
|
||||
source ${ABSDIR}/vars.sh
|
||||
|
||||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
if podman container exists ${container_name}; then
|
||||
echo container ${container_name} alredy exists, please remove it first.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
podman run --name ${container_name} --user nobody -p ${listen_if}:${listen_port}:9000 -d ${upstream_image}:${upstream_version}
|
||||
|
20
podman-peerjs/20_enable.sh
Executable file
20
podman-peerjs/20_enable.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||||
source ${ABSDIR}/../functions.sh
|
||||
source ${ABSDIR}/vars.sh
|
||||
|
||||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
if ! podman container exists ${container_name}; then
|
||||
echo container ${container_name} must exist in order to add it to systemd
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_systemd_as_user_dir_exists
|
||||
podman generate systemd --name ${container_name} > ~/.config/systemd/user/${service_name}
|
||||
|
||||
podman stop ${container_name}
|
||||
systemctl --user enable ${service_name}
|
||||
systemctl --user start ${service_name}
|
15
podman-peerjs/30_start.sh
Executable file
15
podman-peerjs/30_start.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||||
source ${ABSDIR}/../functions.sh
|
||||
source ${ABSDIR}/vars.sh
|
||||
|
||||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
if systemctl is-active --quiet service ${service_name}; then
|
||||
echo Service ${service_name} is already running.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
systemctl --user start ${service_name}.service
|
15
podman-peerjs/40_stop.sh
Executable file
15
podman-peerjs/40_stop.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||||
source ${ABSDIR}/../functions.sh
|
||||
source ${ABSDIR}/vars.sh
|
||||
|
||||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
if ! systemctl is-active --quiet service ${service_name}; then
|
||||
echo Service ${service_name} is already stopped.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
systemctl --user stop ${service_name}.service
|
20
podman-peerjs/80_disable.sh
Executable file
20
podman-peerjs/80_disable.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
||||
source ${ABSDIR}/../functions.sh
|
||||
source ${ABSDIR}/vars.sh
|
||||
|
||||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
if ! podman container exists ${container_name}; then
|
||||
echo container ${container_name} must exist in order to add it to systemd
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_systemd_as_user_dir_exists
|
||||
podman generate systemd --name ${container_name} > ~/.config/systemd/user/${service_name}
|
||||
|
||||
podman stop ${container_name}
|
||||
systemctl --user disable ${service_name}
|
||||
systemctl --user stop ${service_name}
|
8
podman-peerjs/vars.sh
Normal file
8
podman-peerjs/vars.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
container_name='peerjs-server'
|
||||
service_name="container_${container_name}.service"
|
||||
listen_if='127.0.0.1'
|
||||
listen_port='9000'
|
||||
upstream_image='docker.io/peerjs/peerjs-server'
|
||||
upstream_version='0.6.1'
|
Loading…
Reference in a new issue