1+ #! /usr/bin/env bash
2+
3+ # Copyright (c) 2021-2025 community-scripts ORG
4+ # Author: Slaviša Arežina (tremor021)
5+ # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+ # Source: https://github.com/sbondCo/Watcharr
7+
8+ source /dev/stdin <<< " $FUNCTIONS_FILE_PATH"
9+ color
10+ verb_ip6
11+ catch_errors
12+ setting_up_container
13+ network_check
14+ update_os
15+
16+ msg_info " Installing Dependencies"
17+ $STD apt-get install -y \
18+ curl \
19+ sudo \
20+ mc \
21+ gcc \
22+ gnupg
23+ msg_ok " Installed Dependencies"
24+
25+ msg_info " Setup Golang"
26+ set +o pipefail
27+ temp_file=$( mktemp)
28+ golang_tarball=$( curl -s https://go.dev/dl/ | grep -oP ' go[\d\.]+\.linux-amd64\.tar\.gz' | head -n 1)
29+ wget -q https://golang.org/dl/" $golang_tarball " -O " $temp_file "
30+ tar -C /usr/local -xzf " $temp_file "
31+ ln -sf /usr/local/go/bin/go /usr/local/bin/go
32+ rm -f " $temp_file "
33+ set -o pipefail
34+ msg_ok " Setup Golang"
35+
36+ msg_info " Setup Node.js"
37+ mkdir -p /etc/apt/keyrings
38+ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
39+ echo " deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
40+ $STD apt-get update
41+ $STD apt-get install -y nodejs
42+ msg_ok " Setup Node.js"
43+
44+ msg_info " Setup Watcharr"
45+ temp_file=$( mktemp)
46+ RELEASE=$( curl -s https://api.github.com/repos/sbondCo/Watcharr/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
47+ wget -q " https://github.com/sbondCo/Watcharr/archive/refs/tags/v${RELEASE} .tar.gz" -O " $temp_file "
48+ tar -xzf " $temp_file "
49+ mv Watcharr-${RELEASE} / /opt/watcharr
50+ cd /opt/watcharr
51+ $STD npm i
52+ $STD npm run build
53+ mv ./build ./server/ui
54+ cd server
55+ export CGO_ENABLED=1 GOOS=linux
56+ go mod download
57+ go build -o ./watcharr
58+ cat << EOF >/opt/start.sh
59+ #! /bin/bash
60+ source ~/.bashrc
61+ cd /opt/watcharr/server
62+ ./watcharr
63+ EOF
64+ chmod +x /opt/start.sh
65+ echo " ${RELEASE} " > /opt/${APPLICATION} _version.txt
66+ msg_ok " Setup Watcharr"
67+
68+ msg_info " Creating Service"
69+ cat << EOF >/etc/systemd/system/watcharr.service
70+ [Unit]
71+ Description=Watcharr Service
72+ After=network.target
73+
74+ [Service]
75+ WorkingDirectory=/opt/watcharr/server
76+ ExecStart=/opt/start.sh
77+ Restart=always
78+ User=root
79+
80+ [Install]
81+ WantedBy=multi-user.target
82+ EOF
83+ systemctl enable -q --now watcharr
84+ msg_ok " Created Service"
85+
86+ motd_ssh
87+ customize
88+
89+ msg_info " Cleaning up"
90+ rm -f " $temp_file "
91+ $STD apt-get -y autoremove
92+ $STD apt-get -y autoclean
93+ msg_ok " Cleaned"
0 commit comments