Prepare for mrc-server
This commit is contained in:
parent
b65de93103
commit
294dce1e74
@ -13,7 +13,7 @@ APP="Mystic"
|
|||||||
MSDIR="/opt/mystic"
|
MSDIR="/opt/mystic"
|
||||||
TMP_DIR=$(mktemp -d)
|
TMP_DIR=$(mktemp -d)
|
||||||
|
|
||||||
apt install lsb-release dpkg-dev -y &>/dev/null
|
apt install lsb-release dpkg-dev wget curl figlet lolcat -y &>/dev/null
|
||||||
|
|
||||||
ARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)
|
ARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)
|
||||||
|
|
||||||
@ -95,22 +95,7 @@ while true; do
|
|||||||
done
|
done
|
||||||
clear
|
clear
|
||||||
function header_info {
|
function header_info {
|
||||||
echo -e "${BL}
|
/usr/bin/env figlet -w 60 -c "Mystic BBS DbP Installer" | /usr/games/lolcat -f
|
||||||
__ __ _ _ ____ ____ _____
|
|
||||||
| \/ | | | (_) | _ \| _ \ / ____|
|
|
||||||
| \ / |_ _ ___| |_ _ ___ | |_) | |_) | (___
|
|
||||||
| |\/| | | | / __| __| |/ __| | _ <| _ < \___ \
|
|
||||||
| | | | |_| \__ \ |_| | (__ | |_) | |_) |____) |
|
|
||||||
|_| |_|\__, |___/\__|_|\___| |____/|____/|_____/
|
|
||||||
__/ |
|
|
||||||
_____ _ |___/ _____ _ _ _
|
|
||||||
| __ \| | | __ \ |_ _| | | | | |
|
|
||||||
| | | | |__ | |__) | | | _ __ ___| |_ __ _| | | ___ _ __
|
|
||||||
| | | | '_ \| ___/ | | | '_ \/ __| __/ _ | | |/ _ \ __|
|
|
||||||
| |__| | |_) | | _| |_| | | \__ \ || (_| | | | __/ |
|
|
||||||
|_____/|_ __/|_| |_____|_| |_|___/\__\__ _|_|_|\___|_|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header_info
|
header_info
|
||||||
@ -229,9 +214,9 @@ fi
|
|||||||
|
|
||||||
if [ "${CODENAME}" = "bookworm" ]; then
|
if [ "${CODENAME}" = "bookworm" ]; then
|
||||||
msg_info "adding bullseye repository to bookworm for python2"
|
msg_info "adding bullseye repository to bookworm for python2"
|
||||||
echo "deb http://deb.debian.org/debian bullseye contrib non-free main" > /etc/apt/sources.list.d/bullseye &>/dev/null
|
echo "deb http://deb.debian.org/debian bullseye contrib non-free main" > /etc/apt/sources.list.d/bullseye.list
|
||||||
echo "deb http://deb.debian.org/debian bullseye-updates contrib non-free main" >> /etc/apt/sources.list.d/bullseye &>/dev/null
|
echo "deb http://deb.debian.org/debian bullseye-updates contrib non-free main" >> /etc/apt/sources.list.d/bullseye.list
|
||||||
echo "deb http://security.debian.org bullseye-security contrib non-free main" >> /etc/apt/sources.list.d/bullseye &>/dev/null
|
echo "deb http://security.debian.org bullseye-security contrib non-free main" >> /etc/apt/sources.list.d/bullseye.list
|
||||||
apt update &>/dev/null
|
apt update &>/dev/null
|
||||||
msg_ok "Finisched adding bullseye repository"
|
msg_ok "Finisched adding bullseye repository"
|
||||||
fi
|
fi
|
||||||
@ -329,7 +314,7 @@ popd &>/dev/null
|
|||||||
msg_ok "Setting up Multi Relay Chat for ${APP}"
|
msg_ok "Setting up Multi Relay Chat for ${APP}"
|
||||||
|
|
||||||
msg_info "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
msg_info "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
||||||
pushd /usr/local/src/mystic/mystic/mrc &>/dev/null
|
pushd /usr/local/src/mystic/mystic/mrc-client &>/dev/null
|
||||||
bash install-${SCRIPT_VER}.sh $MYSTIC_DIR &>/dev/null
|
bash install-${SCRIPT_VER}.sh $MYSTIC_DIR &>/dev/null
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
msg_ok "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
msg_ok "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
||||||
@ -350,7 +335,9 @@ mkdir -p /usr/local/src/mystic/cryptlib-3.4.5 &>/dev/null
|
|||||||
pushd /usr/local/src/mystic/cryptlib-3.4.5 &>/dev/null
|
pushd /usr/local/src/mystic/cryptlib-3.4.5 &>/dev/null
|
||||||
unzip ../cryptlib345.zip &>/dev/null
|
unzip ../cryptlib345.zip &>/dev/null
|
||||||
dos2unix tools/* &>/dev/null
|
dos2unix tools/* &>/dev/null
|
||||||
|
dos2unix kernel/* &>/dev/null
|
||||||
patch -p1 -i /usr/local/src/mystic/mystic/cryptlib/gccversion-345.patch &>/dev/null
|
patch -p1 -i /usr/local/src/mystic/mystic/cryptlib/gccversion-345.patch &>/dev/null
|
||||||
|
patch -p0 -i /usr/local/src/mystic/mystic/cryptlib/cl-linux-yield.patch &>/dev/null
|
||||||
ln -sf gcc-9 /usr/bin/gcc &>/dev/null
|
ln -sf gcc-9 /usr/bin/gcc &>/dev/null
|
||||||
ln -sf g++-9 /usr/bin/g++ &>/dev/null
|
ln -sf g++-9 /usr/bin/g++ &>/dev/null
|
||||||
ln -sf cpp-9 /usr/bin/cpp &>/dev/null
|
ln -sf cpp-9 /usr/bin/cpp &>/dev/null
|
||||||
@ -463,7 +450,8 @@ fi
|
|||||||
if [ $DOSEMU = "Yes" ]; then
|
if [ $DOSEMU = "Yes" ]; then
|
||||||
msg_info "Installing DosEmu2 Dependencies for ${APP}"
|
msg_info "Installing DosEmu2 Dependencies for ${APP}"
|
||||||
pushd /usr/local/src/mystic &>/dev/null
|
pushd /usr/local/src/mystic &>/dev/null
|
||||||
echo "deb [trusted=yes] https://ppa.launchpadcontent.net/dosemu2/ppa/ubuntu $DIST main" | tee /etc/apt/sources.list.d/dosemu2.list &>/dev/null
|
curl 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x6d9cd73b401a130336ed0a56ebe1b5ded2ad45d6' | tee /etc/apt/trusted.gpg.d/code.launchpad.net-dosemu2.asc &>/dev/null
|
||||||
|
echo "deb https://ppa.launchpadcontent.net/dosemu2/ppa/ubuntu $DIST main" | tee /etc/apt/sources.list.d/dosemu2.list &>/dev/null
|
||||||
apt update &>/dev/null
|
apt update &>/dev/null
|
||||||
apt install -y dosemu2 &>/dev/null
|
apt install -y dosemu2 &>/dev/null
|
||||||
apt install -y install-otherdos &>/dev/null
|
apt install -y install-otherdos &>/dev/null
|
||||||
|
@ -329,7 +329,7 @@ popd &>/dev/null
|
|||||||
msg_ok "Setting up Multi Relay Chat for ${APP}"
|
msg_ok "Setting up Multi Relay Chat for ${APP}"
|
||||||
|
|
||||||
msg_info "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
msg_info "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
||||||
pushd /usr/local/src/mystic/mystic/mrc &>/dev/null
|
pushd /usr/local/src/mystic/mystic/mrc-client &>/dev/null
|
||||||
bash install-${SCRIPT_VER}.sh $MYSTIC_DIR &>/dev/null
|
bash install-${SCRIPT_VER}.sh $MYSTIC_DIR &>/dev/null
|
||||||
popd &>/dev/null
|
popd &>/dev/null
|
||||||
msg_ok "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
msg_ok "Installing Multi Relay Chat Systemd Start/Stop Scripts and Service File"
|
||||||
|
11
mrc-client/install-v1.sh
Normal file
11
mrc-client/install-v1.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MYSTIC_DIR="$1"
|
||||||
|
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-start.sh > ${MYSTIC_DIR}/mrc_client-start
|
||||||
|
chmod +x ${MYSTIC_DIR}/mrc_client-start
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-stop.sh > ${MYSTIC_DIR}/mrc_client-stop
|
||||||
|
chmod +x ${MYSTIC_DIR}/mrc_client-stop
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-client.service > /etc/systemd/system/mrc-client.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
33
mrc-client/mrc-client.service
Normal file
33
mrc-client/mrc-client.service
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#==================================================================================================
|
||||||
|
# This systemd service file can be used to start and stop the 'Multi Relay Chat' python script as #
|
||||||
|
# a proper service module. In order for it to work correctly, it must be set to 'Type=forking'. #
|
||||||
|
# As a forking service, it will decide if start/stop was a failure based on the returned error #
|
||||||
|
# code. A return of 0 will be considered success, and a return of 1 will be a failure. The MRC #
|
||||||
|
# python script should ideally be launched as the same user who owns the mystic directories. To #
|
||||||
|
# do this, be sure to uncomment and set the 'User=' option in the [Service] section below. If you #
|
||||||
|
# don't, the script will be executed as root, which may have security implications. This file is #
|
||||||
|
# indended to work with Debian, Ubuntu, Raspbian and other debian based distributions, but may #
|
||||||
|
# work with others as well. #
|
||||||
|
# #
|
||||||
|
# Be sure to set the location of your mrc-start.sh and mrc-stop.sh scripts in the [Service] #
|
||||||
|
# section below, and to optionally set your user as described above. #
|
||||||
|
#==================================================================================================
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Multi Relay Chat for Mystic BBS
|
||||||
|
After=network.target
|
||||||
|
After=systemd-user-sessions.service
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
Type=forking
|
||||||
|
# Be sure to set 'User' below to the user who owns your mystic directory.
|
||||||
|
User=mystic
|
||||||
|
# Ensure that the paths and filenames below are correct.
|
||||||
|
ExecStart=@MYSTIC_DIR@/mrc_client-start
|
||||||
|
ExecStop=@MYSTIC_DIR@/mrc_client-stop
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
11
mrc-server/install-v1.sh
Normal file
11
mrc-server/install-v1.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MYSTIC_DIR="$1"
|
||||||
|
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-start.sh > ${MYSTIC_DIR}/mrc_server-start
|
||||||
|
chmod +x ${MYSTIC_DIR}/mrc_server-start
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-stop.sh > ${MYSTIC_DIR}/mrc_server-stop
|
||||||
|
chmod +x ${MYSTIC_DIR}/mrc_server-stop
|
||||||
|
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-server.service > /etc/systemd/system/mrc-server.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
33
mrc-server/mrc-server.service
Normal file
33
mrc-server/mrc-server.service
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#==================================================================================================
|
||||||
|
# This systemd service file can be used to start and stop the 'Multi Relay Chat' python script as #
|
||||||
|
# a proper service module. In order for it to work correctly, it must be set to 'Type=forking'. #
|
||||||
|
# As a forking service, it will decide if start/stop was a failure based on the returned error #
|
||||||
|
# code. A return of 0 will be considered success, and a return of 1 will be a failure. The MRC #
|
||||||
|
# python script should ideally be launched as the same user who owns the mystic directories. To #
|
||||||
|
# do this, be sure to uncomment and set the 'User=' option in the [Service] section below. If you #
|
||||||
|
# don't, the script will be executed as root, which may have security implications. This file is #
|
||||||
|
# indended to work with Debian, Ubuntu, Raspbian and other debian based distributions, but may #
|
||||||
|
# work with others as well. #
|
||||||
|
# #
|
||||||
|
# Be sure to set the location of your mrc-start.sh and mrc-stop.sh scripts in the [Service] #
|
||||||
|
# section below, and to optionally set your user as described above. #
|
||||||
|
#==================================================================================================
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Multi Relay Chat Server for Mystic BBS
|
||||||
|
After=network.target
|
||||||
|
After=systemd-user-sessions.service
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
Type=forking
|
||||||
|
# Be sure to set 'User' below to the user who owns your mystic directory.
|
||||||
|
User=mystic
|
||||||
|
# Ensure that the paths and filenames below are correct.
|
||||||
|
ExecStart=@MYSTIC_DIR@/mrc_server-start
|
||||||
|
ExecStop=@MYSTIC_DIR@/mrc_server-stop
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
45
mrc-server/mrc-start.sh
Executable file
45
mrc-server/mrc-start.sh
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#==================================================================================================
|
||||||
|
# This shell script will launch the 'Multi Relay Chat' python script. It is intended to be called #
|
||||||
|
# via a forked systemd .service file. The script will check that mrc_client.py is not already #
|
||||||
|
# running then will launch it. To avoid problems, it should be launched using the same user that #
|
||||||
|
# owns the mystic install directory. If executing manually, use 'sudo -u username' or ensure you #
|
||||||
|
# are logged into the terminal as the user that owns the mystic directory. In a systemd .service #
|
||||||
|
# file, you should use the 'User=' option in the [Service] section. The script will exit with an #
|
||||||
|
# appropriate error code to indicate whether is was successful or not. This script is indended to #
|
||||||
|
# work only with Debian, Ubuntu, Raspbian and other debian based distributions. #
|
||||||
|
#==================================================================================================
|
||||||
|
|
||||||
|
# MRC Variables:
|
||||||
|
MRC_PATH=@MYSTIC_DIR@
|
||||||
|
MRC_SERVER=mrc.bottomlessabyss.net
|
||||||
|
MRC_PORT=5000
|
||||||
|
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
|
||||||
|
|
||||||
|
echo "Attempting to start the Multi Relay Chat (MRC) python script.."
|
||||||
|
|
||||||
|
# Make sure the mrc_client.py script isn't already running:
|
||||||
|
if [ ! -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "Error: mrc_client.py script is already running at PID $MRC_PID. Stop it first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Starting the MRC python script
|
||||||
|
cd $MRC_PATH >/dev/null
|
||||||
|
/usr/bin/python2 ./mrc_client.py $MRC_SERVER $MRC_PORT &
|
||||||
|
cd - >/dev/null
|
||||||
|
|
||||||
|
# Wait 3 seconds and check for a PID
|
||||||
|
sleep 3
|
||||||
|
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
|
||||||
|
|
||||||
|
# Making sure it started successfully
|
||||||
|
if [ ! -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "Success! The mrc_client.py script is now running with PID $MRC_PID"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Error: mrc_client.py failed to start. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
65
mrc-server/mrc-stop.sh
Executable file
65
mrc-server/mrc-stop.sh
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#==================================================================================================
|
||||||
|
# This shell script will stop the 'Multi Relay Chat' python script. It is intended to be called #
|
||||||
|
# via a forked systemd .service file. The script will check that mrc_client.py is running then #
|
||||||
|
# will stop it via SIGTERM. If it can't be stopped gracefully within 30 seconds, it will be #
|
||||||
|
# forcefully stopped. The script will exit with an appropriate error code to indicate whether it #
|
||||||
|
# was successful or not. This script is indended to work only with Debian, Ubuntu, Raspbian and #
|
||||||
|
# other debian based distributions. #
|
||||||
|
#==================================================================================================
|
||||||
|
|
||||||
|
# MRC Variables. Be sure to set your MRC script path (usually your main mystic directory)
|
||||||
|
MRC_PATH=@MYSTIC_DIR@
|
||||||
|
MRC_SERVER=mrc.bottomlessabyss.net
|
||||||
|
MRC_PORT=5000
|
||||||
|
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
|
||||||
|
|
||||||
|
echo "Attempting to stop the Multi Relay Chat (MRC) python script.."
|
||||||
|
|
||||||
|
# Make sure the mrc_client.py script is running:
|
||||||
|
if [ -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "Error: mrc_client.py is not running so can't be stopped."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Stopping the MRC python script
|
||||||
|
echo "The MRC PID is $MRC_PID. Sending a SIGTERM.."
|
||||||
|
kill -s TERM $MRC_PID
|
||||||
|
|
||||||
|
# Making sure it stopped successfully
|
||||||
|
MRC_COUNTER=0
|
||||||
|
echo "Checking to ensure the process stops.."
|
||||||
|
|
||||||
|
while [ $MRC_COUNTER -lt 6 ]
|
||||||
|
do
|
||||||
|
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
|
||||||
|
if [ ! -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "Process still running. Waiting 5 seconds.."
|
||||||
|
sleep 5
|
||||||
|
else
|
||||||
|
echo "Finished! mrc_client.py script has been stopped successfully."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
let MRC_COUNTER=MRC_COUNTER+1
|
||||||
|
done
|
||||||
|
|
||||||
|
# If it's still running after 30 seconds (6 intervals) then use kill -9
|
||||||
|
if [ "$MRC_COUNTER" -eq 6 ] && [ ! -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "The mrc_client.py script failed to stop after 60 seconds. Stopping forcefully.."
|
||||||
|
kill -9 $MRC_PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait 5 seconds, then double check to ensure it stopped. Otherwise it's considered a failure.
|
||||||
|
sleep 5
|
||||||
|
MRC_PID=$(ps auxwww | grep "/usr/bin/python2 ./mrc_client.py" | grep -v grep | awk '{print $2}')
|
||||||
|
if [ ! -z "$MRC_PID" ]
|
||||||
|
then
|
||||||
|
echo "Error: Failed to kill the mrc_client.py script."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Success. The mrc_client.py script was forcefully stopped."
|
||||||
|
exit 0
|
||||||
|
fi
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
MYSTIC_DIR="$1"
|
|
||||||
|
|
||||||
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-start.sh > ${MYSTIC_DIR}/mrc-start
|
|
||||||
chmod +x ${MYSTIC_DIR}/mrc-start
|
|
||||||
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc-stop.sh > ${MYSTIC_DIR}/mrc-stop
|
|
||||||
chmod +x ${MYSTIC_DIR}/mrc-stop
|
|
||||||
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mrc.service > /etc/systemd/system/mrc.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user