Install script
This commit is contained in:
parent
ae56590bb9
commit
5fcecde568
2 changed files with 80 additions and 0 deletions
65
install.sh
Normal file
65
install.sh
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
sudo $0
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo Installing requirements...
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
VER=$VERSION_ID
|
||||||
|
ID=$ID
|
||||||
|
elif type lsb_release >/dev/null 2>&1; then
|
||||||
|
OS=$(lsb_release -si)
|
||||||
|
VER=$(lsb_release -sr)
|
||||||
|
ID=$ID
|
||||||
|
else
|
||||||
|
echo WARNING: Unknown OS. Please install tmux by hand.
|
||||||
|
echo This script may error during install.
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ID" -eq "ubuntu" ] || [ "$ID" -eq "debian" ]; then
|
||||||
|
apt update
|
||||||
|
apt install tmux python3 python3-pip -y
|
||||||
|
elif [ "$ID" -eq "arch" ] || [ "$ID" -eq "manjaro" ]; then
|
||||||
|
pacman -Sy tmux python python-pip
|
||||||
|
fi
|
||||||
|
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
if [ ! -d "/home/jarvis" ]; then
|
||||||
|
echo Creating user jarvis...
|
||||||
|
useradd -m jarvis
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/jarvis/j.a.r.v.i.s." ]; then
|
||||||
|
echo Copying J.A.R.V.I.S. files...
|
||||||
|
mkdir -p /home/jarvis/j.a.r.v.i.s.
|
||||||
|
cp -r * /home/jarvis/j.a.r.v.i.s./
|
||||||
|
chown -r jarvis:jarvis /home/jarvis/j.a.r.v.i.s.
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Creating ssh config for updates...
|
||||||
|
sudo -u jarvis mkdir -p /home/jarvis/.ssh
|
||||||
|
sudo -u jarvis ssh-keygen -q -t ed25519 -n "j.a.r.v.i.s." -f /home/jarvis/.ssh/id_ed25519
|
||||||
|
cat << 'EOF' >> /home/jarvis/.ssh/config
|
||||||
|
Host git.zevaryx.com
|
||||||
|
HostName git.zevaryx.com
|
||||||
|
Port 22
|
||||||
|
User git
|
||||||
|
IdentityFile /home/jarvis/.ssh/id_ed25519
|
||||||
|
EOF
|
||||||
|
chown jarvis:jarvis /home/jarvis/.ssh/config
|
||||||
|
|
||||||
|
echo Give this key to your local admin:
|
||||||
|
cat /home/jarvis/.ssh/id_ed25519.pub
|
||||||
|
|
||||||
|
if [ ! -f "/etc/systemd/system/jarvis.service" ]; then
|
||||||
|
echo Installing systemd service...
|
||||||
|
cp jarvis.service /etc/systemd/system/jarvis.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
|
echo Enabling J.A.R.V.I.S.
|
||||||
|
systemctl enable --now jarvis.service
|
||||||
|
|
||||||
|
echo J.A.R.V.I.S. should now be online.
|
||||||
|
echo Connect to console using tmux -a jarvis
|
15
jarvis.service
Normal file
15
jarvis.service
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[Unit]
|
||||||
|
Description=J.A.R.V.I.S. via tmux (detached)
|
||||||
|
Documentation=man:tmux(1)
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=jarvis
|
||||||
|
Group=jarvis
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStart=/usr/bin/tmux new-session -d -s jarvis "/home/jarvis/j.a.r.v.i.s./run.py"
|
||||||
|
ExecStop=/usr/bin/tmux kill-server
|
||||||
|
KillMode = none
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multiplexer.target
|
Loading…
Add table
Reference in a new issue