Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix - rclone upgrade, and added function #865

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
37 changes: 20 additions & 17 deletions scripts/install/rclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,27 @@
# including (via compiler) GPL-licensed code must also be made available
# under the GPL along with build & install instructions.

# Install fuse
apt_install fuse
sed -i -e 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
#shellcheck source=sources/functions/utils
. /etc/swizzin/sources/functions/utils
#shellcheck source=sources/functions/rclone
. /etc/swizzin/sources/functions/rclone

echo_progress_start "Downloading and installing rclone"
# One-liner to check arch/os type, as well as download latest rclone for relevant system.
wget -q https://rclone.org/install.sh -O /tmp/rcloneinstall.sh >> $log 2>&1
_systemd() {
type="simple"
if [[ $(systemctl --version | awk 'NR==1 {print $2}') -ge 240 ]]; then
type="exec"
else
type="simple"
fi

# Make sure rclone downloads and installs without error before proceeding
if ! bash /tmp/rcloneinstall.sh; then
echo_error "Rclone installer failed"
exit 1
fi

echo_progress_start "Adding rclone multi-user mount service"
cat > /etc/systemd/system/rclone@.service << EOF
echo_progress_start "Installing Systemd service"
cat > /etc/systemd/system/rclone@.service << EOF
[Unit]
Description=rclonemount
After=network.target

[Service]
Type=simple
Type=${type}
User=%i
Group=%i
ExecStartPre=-/bin/mkdir -p /home/%i/cloud/
Expand All @@ -63,9 +62,13 @@ StartLimitBurst=3

[Install]
WantedBy=multi-user.target

EOF
echo_progress_done

echo_progress_done
}

_rclone_download_latest
_systemd

touch /install/.rclone.lock
echo_success "Rclone installed"
Expand Down
23 changes: 23 additions & 0 deletions scripts/upgrade/rclone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# rclone upgrader
# byte 2022 for Swizzin

#shellcheck source=sources/functions/utils
. /etc/swizzin/sources/functions/utils
#shellcheck source=sources/functions/rclone
. /etc/swizzin/sources/functions/rclone
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users are never defined if you’re going to be looping through them to restart the services.


if [[ ! -f /install/.rclone.lock ]]; then
echo_error "rclone doesn't appear to be installed!"
exit 1
fi

_restart_rclone() {
systemctl try-restart "rclone@"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try-restart rclone@ won’t work. You need to loop through the users.

echo_progress_done "Service restarted"
}

_rclone_download_latest
_restart_rclone

echo_success "rclone upgraded"
19 changes: 19 additions & 0 deletions sources/functions/rclone
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Install fuse
function _fuse() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really doesn’t need to be its own function. It only needs to run on install.

apt_install fuse
sed -i -e 's/#user_allow_other/user_allow_other/' /etc/fuse.conf
}

function _rclone_download_latest() {
echo_progress_start "Downloading and installing rclone"
# One-liner to check arch/os type, as well as download latest rclone for relevant system.
wget -q https://rclone.org/install.sh -O /tmp/rcloneinstall.sh >> "${log}" 2>&1

# Make sure rclone downloads and installs without error before proceeding
if ! bash /tmp/rcloneinstall.sh; then
echo_error "Rclone installer failed"
exit 1
fi
}