From 2a81c8856899fe98277a8c09c06d48fd97e5f953 Mon Sep 17 00:00:00 2001 From: GoldenSpring Date: Mon, 22 Dec 2025 02:20:10 +0300 Subject: [PATCH] added the installation script --- install/rustypaste-install.sh | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 install/rustypaste-install.sh diff --git a/install/rustypaste-install.sh b/install/rustypaste-install.sh new file mode 100644 index 000000000..dd37538e7 --- /dev/null +++ b/install/rustypaste-install.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: GoldenSpringness +# License: MIT | https://github.com/GoldenSpringness/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/orhun/rustypaste + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + git \ + build-essential \ + ca-certificates +msg_ok "Dependencies Installed Successfully" + +setup_rust + +msg_info "Setting up ${APPLICATION}" +# Getting the latest release version +RELEASE=$(curl -s https://api.github.com/repos/orhun/rustypaste/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /opt +git clone https://github.com/orhun/rustypaste.git + +if [[ ! -d "/opt/${APPLICATION}" ]]; then + msg_error "Git clone has failed" + exit +fi + +cd ${APPLICATION} +git fetch --tags +git switch --detach ${RELEASE} # checking out to latest release + +sed -i 's|^address = ".*"|address = "0.0.0.0:8000"|' config.toml # changing the ip and port + +msg_info "Compiling ${APPLICATION}" +cargo build --locked --release # creating the binary + +if [[ ! -f "/opt/${APPLICATION}/target/release/rustypaste" ]]; then + msg_error "Cargo build failed" + exit +fi + +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt # creating version file for the update function +msg_ok "Setting up ${APPLICATION} is Done!" + +# Creating Service (if needed) +msg_info "Creating Service" +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=${APPLICATION} Service +After=network.target + +[Service] +WorkingDirectory=/opt/rustypaste +ExecStart=/opt/${APPLICATION}/target/release/rustypaste +Restart=always + +[Install] +WantedBy=multi-user.target +EOF + +systemctl enable -q --now ${APPLICATION}.service +msg_ok "Created Service" + +msg_ok "RustyPaste is Running!" + +motd_ssh +customize + +# Cleanup +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"