summary refs log tree commit diff
path: root/deploy.sh
diff options
context:
space:
mode:
authorLain Iwakura <lain@lainmail.xyz>2026-01-04 04:01:15 +0300
committerLain Iwakura <lain@lainmail.xyz>2026-01-04 04:01:15 +0300
commitff4598371937c94db6b792ed42afa241b1e1f35c (patch)
tree1fba1edb95456b9385a65704b37f331a7fe3a3a7 /deploy.sh
parentSupport reading gzipped data in merge (diff)
downloadtorus-ff4598371937c94db6b792ed42afa241b1e1f35c.tar.gz
torus-ff4598371937c94db6b792ed42afa241b1e1f35c.zip
feat(main): linux patches
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..0f92cad
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -e
+CHROOT_USER=torus
+CHROOT_GROUP=torus
+INSTALL_DIR=/opt/torus
+HOME_DIR=/home/torus
+SOCK_PATH=$HOME_DIR/torus.sock
+DATA_PATH=$HOME_DIR/torus.dat
+PID_PATH=/var/run/torus.pid
+if [ "$EUID" -ne 0 ]; then 
+    exit 1
+fi
+if ! id "$CHROOT_USER" &>/dev/null; then
+    useradd -r -m -s /bin/bash "$CHROOT_USER"
+fi
+passwd -d "$CHROOT_USER" 2>/dev/null || usermod -p "" "$CHROOT_USER"
+mkdir -p "$INSTALL_DIR"
+mkdir -p "$HOME_DIR"
+mkdir -p /var/www/ascii.town
+cp -f client server image merge meta "$INSTALL_DIR/"
+chmod +x "$INSTALL_DIR"/*
+if [ -f default8x16.psfu ]; then
+    mkdir -p "$HOME_DIR/usr/share/torus"
+    cp -f default8x16.psfu "$HOME_DIR/usr/share/torus/"
+fi
+if [ -f explore.html ] && [ -f index.html ]; then
+    cp -f explore.html index.html /var/www/ascii.town/
+    chown -R "$CHROOT_USER:$CHROOT_GROUP" /var/www/ascii.town
+fi
+chown -R "$CHROOT_USER:$CHROOT_GROUP" "$HOME_DIR"
+chown -R "$CHROOT_USER:$CHROOT_GROUP" "$INSTALL_DIR"
+cat > /etc/systemd/system/torus.service << EOF
+[Unit]
+Description=Torus ASCII Art Server
+After=network.target
+
+[Service]
+Type=forking
+User=$CHROOT_USER
+Group=$CHROOT_GROUP
+ExecStart=$INSTALL_DIR/server -d $DATA_PATH -p $PID_PATH -s $SOCK_PATH
+Restart=always
+RestartSec=10
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+if ! grep -q "Match User $CHROOT_USER" /etc/ssh/sshd_config; then
+    cat >> /etc/ssh/sshd_config << EOF
+
+Match User $CHROOT_USER
+	PasswordAuthentication yes
+	PermitEmptyPasswords yes
+	ForceCommand $INSTALL_DIR/client -s $SOCK_PATH
+	DisableForwarding yes
+	MaxSessions 1
+EOF
+else
+fi
+
+echo "--------------------------------"
+echo "passwd -d $CHROOT_USER"
+echo "systemctl restart sshd"
+echo "systemctl enable --now torus"
+echo "systemctl status torus"
\ No newline at end of file