Add alpine rclone script

This commit is contained in:
tremor021 2025-04-10 23:33:49 +02:00
parent 403f08fd63
commit 686e3217cf
2 changed files with 116 additions and 0 deletions

54
ct/alpine-rclone.sh Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/rclone/rclone
APP="Alpine-rclone"
var_tags="${var_tags:-alpine;development}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-256}"
var_disk="${var_disk:-0.2}"
var_os="${var_os:-alpine}"
var_version="${var_version:-3.21}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [ ! -d /opt/rclone ]; then
msg_error "No ${APP} Installation Found!"
exit 1
fi
RELEASE=$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ] || [ ! -f /opt/${APP}_version.txt ]; then
msg_info "Updating ${APP} LXC"
temp_file=$(mktemp)
curl -fsSL "https://github.com/rclone/rclone/releases/download/v${RELEASE}/rclone-v${RELEASE}-linux-amd64.zip" -o $temp_file
$STD unzip -j -o $temp_file '*/**' -d /opt/rclone
rm -f $temp_file
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi
exit 0
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following IP:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/rclone/rclone
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing dependencies"
$STD apk add --no-cache \
unzip \
apache2-utils
msg_ok "Installed dependencies"
msg_info "Installing rclone"
temp_file=$(mktemp)
mkdir -p /opt/rclone
RELEASE=$(curl -s https://api.github.com/repos/rclone/rclone/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
curl -fsSL "https://github.com/rclone/rclone/releases/download/v${RELEASE}/rclone-v${RELEASE}-linux-amd64.zip" -o $temp_file
unzip -j $temp_file '*/**' -d /opt/rclone
cd /opt/rclone
PASSWORD=$(head -c 16 /dev/urandom | xxd -p -c 16)
htpasswd -cb -B login.pwd admin $PASSWORD
{
echo "rclone-Credentials"
echo "rclone User Name: admin"
echo "rclone Password: $PASSWORD"
} >>~/rclone.creds
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
rm -f $temp_file
msg_ok "Installed rclone"
msg_info "Enabling rclone Service"
cat <<EOF >/etc/init.d/rclone
#!/sbin/openrc-run
description="rclone Service"
command="/opt/rclone/rclone"
command_args="rcd --rc-web-gui --rc-web-gui-no-open-browser --rc-addr :3000 --rc-htpasswd /opt/rclone/login.pwd"
command_user="root"
pidfile="/var/run/rclone.pid"
depend() {
use net
}
EOF
chmod +x /etc/init.d/rclone
$STD rc-update add rclone default
msg_ok "Enabled rclone Service"
msg_info "Starting rclone"
$STD service rclone start
msg_ok "Started rclone"
motd_ssh
customize