-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwhisparr.sh
executable file
·135 lines (116 loc) · 3.36 KB
/
whisparr.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
## Installer by b
## Thanks to Bakerboy, Sosig, Liara, and team for some of the functions / logic.
user=$(whoami)
if [[ ! -d $HOME/.logs ]]; then
mkdir -p $HOME/.logs
fi
touch "$HOME/.logs/whisparr.log"
log="$HOME/.logs/whisparr.log"
function port() {
LOW_BOUND=$1
UPPER_BOUND=$2
comm -23 <(seq ${LOW_BOUND} ${UPPER_BOUND} | sort) <(ss -Htan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1
}
function _install() {
ssl_port=$(port 14000 16000)
port=$(port 8000 13000)
domain=$(hostname -f)
# Download App
echo "Downloading Whisparr"
mkdir -p "$HOME/.tmp"
curl -sL "http://whisparr.servarr.com/v1/update/nightly/updatefile?os=linux&runtime=netcore&arch=x64" -o $HOME/.tmp/whisparr.tar.gz >> "$log" 2>&1 || {
echo "Download failed."
exit 1
}
# Extract
echo "Extracting Whisparr"
tar xfv "$HOME/.tmp/whisparr.tar.gz" --directory $HOME/ >> "$log" 2>&1 || {
echo_error "Failed to extract"
exit 1
}
rm -rf /tmp/whisparr.tar.gz
if [[ ! -d $HOME/.config/systemd/user/ ]]; then
mkdir -p $HOME/.config/systemd/user/
fi
# Service File
echo "Writing service file"
cat > "$HOME/.config/systemd/user/whisparr.service" << EOF
[Unit]
Description=Whisparr Daemon
After=syslog.target network.target
[Service]
Type=simple
ExecStart=$HOME/Whisparr/Whisparr -nobrowser -data=$HOME/.config/Whisparr/
TimeoutStopSec=20
KillMode=process
Restart=on-failure
[Install]
WantedBy=default.target
EOF
mkdir -p $HOME/.config/Whisparr/
cat > $HOME/.config/Whisparr/config.xml << WHISPARR
<Config>
<LogLevel>debug</LogLevel>
<UpdateMechanism>BuiltIn</UpdateMechanism>
<BindAddress>*</BindAddress>
<Port>${port}</Port>
<SslPort>${ssl_port}</SslPort>
<EnableSsl>False</EnableSsl>
<LaunchBrowser>False</LaunchBrowser>
<ApiKey></ApiKey>
<AuthenticationMethod>None</AuthenticationMethod>
<UrlBase></UrlBase>
<Branch>develop</Branch>
</Config>
WHISPARR
# Enable/Start Whisparr
echo "Starting Whisparr"
systemctl enable --now --user whisparr.service
touch "$HOME/.install/.whisparr.lock"
echo "Whisparr has been installed. You can access it at http://${domain}:${port}"
echo "Remember to check your authentication. This is publicly accessible and will contain your API keys and stuff."
}
function _remove() {
systemctl disable --now --user whisparr
rm -rf "$HOME/.config/Whisparr/"
rm -rf "$HOME/Whisparr/"
echo "Whisparr has been removed."
}
echo 'This is unsupported software. You will not get help with this, please answer `yes` if you understand and wish to proceed'
if [[ -z ${eula} ]]; then
read -r eula
fi
if ! [[ $eula =~ yes ]]; then
echo "You did not accept the above. Exiting..."
exit 1
else
echo "Proceeding with installation"
fi
echo "Welcome to Whisparr installer..."
echo ""
echo "What do you like to do?"
echo "Logs are stored at ${log}"
echo "install = Install Whisparr"
echo "uninstall = Completely removes Whisparr"
echo "exit = Exits Installer"
while true; do
read -r -p "Enter it here: " choice
case $choice in
"install")
_install
break
;;
"uninstall")
_remove
break
;;
"exit")
break
;;
*)
echo "Unknown Option."
;;
esac
done
exit