diff options
| author | Lain Iwakura <lain@lainmail.xyz> | 2026-01-04 14:19:54 +0300 |
|---|---|---|
| committer | Lain Iwakura <lain@lainmail.xyz> | 2026-01-04 14:19:54 +0300 |
| commit | 9e1fed3c5404ee5e23828665e06e6a2e5c2caa15 (patch) | |
| tree | 7934b7322797fd311899f4fc3626f42707fde7e3 | |
| parent | feat(linux): some patches (diff) | |
| download | play-9e1fed3c5404ee5e23828665e06e6a2e5c2caa15.tar.gz play-9e1fed3c5404ee5e23828665e06e6a2e5c2caa15.zip | |
feat(deploy.sh): some kind of deploy script
| -rwxr-xr-x | deploy.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..5dd4f31 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -e +CHROOT_USER=play +CHROOT_GROUP=play +INSTALL_DIR=/opt/play +HOME_DIR=/home/play + +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" + +make clean || true +make + +cp -f play "$INSTALL_DIR/" +chmod +x "$INSTALL_DIR/play" + +chown -R "$CHROOT_USER:$CHROOT_GROUP" "$HOME_DIR" +chown -R "$CHROOT_USER:$CHROOT_GROUP" "$INSTALL_DIR" + +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/play + DisableForwarding yes + MaxSessions 1 +EOF +fi + +echo "--------------------------------" +echo "passwd -d $CHROOT_USER" +echo "systemctl restart sshd" +echo "ssh -t $CHROOT_USER@localhost" |