-
-
Save sumonst21/681f1c8c55d8579c538343c699575e2c to your computer and use it in GitHub Desktop.
Script to install Duplicati on RHEL/CentOS 7+ (Suitable for headless servers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install dependencies | |
yum install appindicator-sharp libappindicator-sharp mono-core libappindicator -y | |
# Get Duplicati | |
wget https://updates.duplicati.com/beta/duplicati-2.0.5.1-2.0.5.1_beta_20200118.noarch.rpm | |
#Install Duplicati | |
rpm -i duplicati-2.0.5.1-2.0.5.1_beta_20200118.noarch.rpm | |
# Ask for configurations parameters | |
read -p 'Duplicati webserver hostname: ' duplicati_hostname | |
while true | |
do | |
read -p 'Duplicati webserver port [default 8200]: ' duplicati_port | |
[[ $duplicati_port =~ ^([0-9]+|'')$ ]] || { echo "Enter a valid number"; continue; } | |
if (( duplicati_port >= 1 && duplicati_port <= 65535 )); then | |
break; | |
elif [ -z "$duplicati_port" ];then | |
#Set default port | |
duplicati_port=8200 | |
break; | |
else | |
echo "Port not valid!" | |
fi | |
done | |
read -p 'Duplicati webserver ssl certificate path (pkcs12) [Enter blank to use HTTP]: ' ssl_cert_path | |
if [ -n "$ssl_cert_path" ]; then | |
ssl_config="--webservice-sslcertificatefile=$ssl_cert_path" | |
fi | |
# Create systemctl files | |
cat > /etc/systemd/system/duplicati.service << EOF | |
[Unit] | |
Description=Duplicati web-server | |
After=network.target | |
[Service] | |
Nice=19 | |
IOSchedulingClass=idle | |
EnvironmentFile=-/etc/default/duplicati | |
ExecStart=/usr/bin/duplicati-server \$DAEMON_OPTS | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat > /etc/default/duplicati << EOF | |
# Defaults for duplicati initscript | |
# sourced by /etc/init.d/duplicati | |
# installed at /etc/default/duplicati by the maintainer scripts | |
# | |
# This is a POSIX shell fragment | |
# | |
# Additional options that are passed to the Daemon. | |
DAEMON_OPTS="--webservice-port=$duplicati_port --webservice-interface=any --webservice-allowed-hostnames=$duplicati_hostname $ssl_config" | |
EOF | |
# Enable and start duplicati daemon | |
systemctl daemon-reload | |
systemctl enable duplicati | |
systemctl start duplicati | |
# Add CA certificates from Mozilla to avoid "No certificates found" error | |
curl -O https://curl.haxx.se/ca/cacert.pem | |
cert-sync --user cacert.pem | |
rm -f cacert.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment