From 7e1858d5de1d90c6cbaf2a2d06beee95a33124c2 Mon Sep 17 00:00:00 2001 From: szaimen Date: Mon, 19 Oct 2020 20:26:44 +0200 Subject: [PATCH] update ddclient-configuration with new function for reinstalling (#1603) Co-authored-by: Daniel Hansson --- network/ddclient-configuration.sh | 57 ++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/network/ddclient-configuration.sh b/network/ddclient-configuration.sh index c00aa0f5..ced07921 100644 --- a/network/ddclient-configuration.sh +++ b/network/ddclient-configuration.sh @@ -1,10 +1,12 @@ #!/bin/bash # T&M Hansson IT AB © - 2020, https://www.hanssonit.se/ +# Copyright © 2020 Simon Lindner (https://github.com/szaimen) # shellcheck disable=2034,2059 true -SCRIPT_NAME="Setup DDclient" +SCRIPT_NAME="DynDNS with ddclient" +SCRIPT_EXPLAINER="This script lets you setup DynDNS by using the Linux ddclient software." # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh) @@ -17,11 +19,40 @@ debug_mode # Check if root root_check +# Check if ddclient is already installed +if ! is_this_installed ddclient +then + # Ask for installing + install_popup "$SCRIPT_NAME" +else + # Ask for removal or reinstallation + reinstall_remove_menu "$SCRIPT_NAME" + # Removal + apt purge ddclient -y + if is_this_installed libjson-any-perl + then + apt purge libjson-any-perl -y + fi + apt autoremove -y + rm -f /etc/ddclient.conf + # Show successful uninstall if applicable + removal_popup "$SCRIPT_NAME" +fi + +# install needed tool +DEBIAN_FRONTEND=noninteractive apt install ddclient -y + +# Test if file exists +if [ ! -f /etc/ddclient.conf ] +then + msg_box "The default ddclient.conf doesn't seem to exist.\nPlease report this to\n$ISSUES." + exit 1 +fi + choice=$(whiptail --title "$TITLE" --menu \ -"This script lets you setup DynDNS by using the ddclient application. -You have to setup an account before you can start.\n\nPlease choose your DynDNS-Provider. -$MENU_GUIDE\n\n$RUN_LATER_GUIDE -If your DDNS provider isn't already supported, please open a new issue here:\n$ISSUES" "$WT_HEIGHT" "$WT_WIDTH" 4 \ +"Please choose your DynDNS-Provider.\nYou have to setup an account before you can start.\n +If your DDNS provider isn't already supported, please open a new issue here:\n$ISSUES +$MENU_GUIDE\n\n$RUN_LATER_GUIDE" "$WT_HEIGHT" "$WT_WIDTH" 4 \ "Cloudflare" "(cloudflare.com)" \ "deSEC" "(desec.io)" \ "Duck DNS" "(duckdns.org)" \ @@ -69,7 +100,7 @@ case "$choice" in esac # Instructions -msg_box "Before you can continue, you have to access $PROVIDER and $INSTRUCTIONS.\nHere is a guide:\n$GUIDE" +msg_box "Before you can continue, you have to access $PROVIDER and $INSTRUCTIONS.\n\nHere is a guide:\n$GUIDE" # Ask if everything is prepared if ! yesno_box_yes "Are you ready to continue?" @@ -108,20 +139,6 @@ then install_if_not libjson-any-perl fi -# Install ddclient -if ! is_this_installed ddclient -then - print_text_in_color "$ICyan" "Installing ddclient..." - # This creates a ddclient service, creates a /etc/default/ddclient file and a /etc/ddclient.conf file - DEBIAN_FRONTEND=noninteractive apt install ddclient -y -fi - -if [ ! -f /etc/ddclient.conf ] -then - msg_box "The default ddclient.conf doesn't seem to exist.\nPlease report this to\n$ISSUES." - exit 1 -fi - # Write information to ddclient.conf cat << DDCLIENT_CONF > "/etc/ddclient.conf" # Configuration file for ddclient generated by debconf