Skip to content

Commit d956763

Browse files
authored
Refactor (#6202)
1 parent af4aedf commit d956763

2 files changed

Lines changed: 7 additions & 20 deletions

File tree

ct/duplicati.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,19 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30+
3031
RELEASE=$(curl -fsSL https://api.github.com/repos/duplicati/duplicati/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
31-
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.duplicati)" ]] || [[ ! -f ~/.duplicati ]]; then
3233
msg_info "Stopping $APP"
3334
systemctl stop duplicati
3435
msg_ok "Stopped $APP"
35-
msg_info "Updating $APP to v${RELEASE}"
36-
curl -fsSL "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb" -o $(basename "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb")
37-
$STD dpkg -i duplicati-${RELEASE}-linux-x64-gui.deb
38-
echo "${RELEASE}" >/opt/${APP}_version.txt
39-
msg_ok "Updated $APP to v${RELEASE}"
36+
37+
fetch_and_deploy_gh_release "duplicati" "duplicati/duplicati" "binary" "latest" "/opt/duplicati" "linux-x64-gui.deb"
4038

4139
msg_info "Starting $APP"
4240
systemctl start duplicati
4341
msg_ok "Started $APP"
4442

45-
msg_info "Cleaning Up"
46-
rm -rf ~/duplicati-${RELEASE}-linux-x64-gui.deb
47-
msg_ok "Cleanup Completed"
48-
4943
msg_ok "Update Successful"
5044
else
5145
msg_ok "No update required. ${APP} is already at v${RELEASE}"

install/duplicati-install.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,16 @@ $STD apt-get install -y \
2020
libfontconfig1
2121
msg_ok "Installed Dependencies"
2222

23-
msg_info "Setting up Duplicati"
24-
RELEASE=$(curl -fsSL https://api.github.com/repos/duplicati/duplicati/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
25-
curl -fsSL "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb" -o "duplicati-${RELEASE}-linux-x64-gui.deb"
26-
$STD dpkg -i duplicati-${RELEASE}-linux-x64-gui.deb
27-
echo "${RELEASE}" >/opt/Duplicati_version.txt
28-
msg_ok "Finished setting up Duplicati"
23+
fetch_and_deploy_gh_release "duplicati" "duplicati/duplicati" "binary" "latest" "/opt/duplicati" "linux-x64-gui.deb"
2924

25+
msg_info "Configuring duplicati"
3026
DECRYPTKEY=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
3127
ADMINPASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
3228
{
3329
echo "Admin password = ${ADMINPASS}"
3430
echo "Database encryption key = ${DECRYPTKEY}"
3531
} >>~/duplicati.creds
32+
msg_ok "Configured duplicati"
3633

3734
msg_info "Creating Service"
3835
cat <<EOF >/etc/systemd/system/duplicati.service
@@ -54,10 +51,6 @@ motd_ssh
5451
customize
5552

5653
msg_info "Cleaning up"
57-
rm -f duplicati-${RELEASE}-linux-x64-gui.deb
5854
$STD apt-get -y autoremove
5955
$STD apt-get -y autoclean
6056
msg_ok "Cleaned"
61-
62-
motd_ssh
63-
customize

0 commit comments

Comments
 (0)