-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
45 lines (35 loc) · 937 Bytes
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Request root access
sudo echo "Root access granted"
# Setup dependencies
sudo apt install python3 python3-venv
# Set variables
PROJECT_DIR="/home/$(whoami)/.config/totp-auth"
VENV_DIR="${PROJECT_DIR}/venv"
# Create project directory
mkdir -p "$PROJECT_DIR"
cd "$PROJECT_DIR"
# Setup virtual environment
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
pip3 install totp-auth
# Create systemd service file
cat <<EOF | sudo tee /etc/systemd/system/totp-auth.service > /dev/null
[Unit]
Description=TOTP Auth Service
After=network.target
[Service]
User=$(whoami)
WorkingDirectory=$PROJECT_DIR
ExecStart=$VENV_DIR/bin/totp-auth run
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd and start the service
sudo systemctl daemon-reload
sudo systemctl enable totp-auth
sudo systemctl start totp-auth
# Symlink for script
sudo ln -s $VENV_DIR/bin/totp-auth /usr/bin/totp-auth