tmuxviewer/install.sh

51 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2022-01-17 11:33:57 +01:00
#!/usr/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit 1
fi
2022-01-17 11:57:58 +01:00
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/"
2022-01-17 11:33:57 +01:00
VIEWER="tmuxviewer"
SSHD_CONFIG_FOLDER="/etc/ssh/sshd_config.d/"
2022-03-19 11:04:22 +01:00
CONFIG_FILE="$VIEWER.conf"
2022-01-17 11:33:57 +01:00
CONFIG_FILE_PATH="$SSHD_CONFIG_FOLDER$CONFIG_FILE"
BIN_FOLDER="/usr/bin/"
VIEWER_BIN="tmux_viewer.sh"
BROADCAST_BIN="tmux_broadcast.sh"
function install_tmuxviewer () {
2022-03-23 13:01:26 +01:00
apt-get install -y tmux openssh-server
2022-01-17 11:33:57 +01:00
echo "adding $VIEWER_BIN and $BROADCAST_BIN to $BIN_FOLDER"
2022-03-23 13:01:26 +01:00
cp $SCRIPT_DIR$VIEWER_BIN $BIN_FOLDER$VIEWER_BIN
cp $SCRIPT_DIR$BROADCAST_BIN $BIN_FOLDER$BROADCAST_BIN
2022-01-17 11:33:57 +01:00
echo "adding user $VIEWER"
2022-03-23 13:01:26 +01:00
useradd --home /tmp/$VIEWER --shell /usr/bin/tmux_viewer.sh $VIEWER
2022-01-17 11:33:57 +01:00
echo "unsetting password for $VIEWER"
2022-03-23 13:01:26 +01:00
passwd -d $VIEWER 1> /dev/null
mkdir -p $SSHD_CONFIG_FOLDER
echo -e "Match User $VIEWER\n\tPermitEmptyPasswords yes" > $CONFIG_FILE_PATH
#sudo systemctl restart sshd.service
2022-01-17 11:33:57 +01:00
}
function uninstall_tmuxviewer () {
echo "removing user $VIEWER"
2022-03-23 13:01:26 +01:00
userdel $VIEWER
rm $CONFIG_FILE_PATH
rm $BIN_FOLDER$VIEWER_BIN
rm $BIN_FOLDER$BROADCAST_BIN
2022-01-17 11:33:57 +01:00
}
case $1 in
install)
uninstall_tmuxviewer 2> /dev/null
install_tmuxviewer
;;
uninstall)
uninstall_tmuxviewer
;;
*)
echo "usage (as root): $0 [install|uninstall]"
;;
esac