Refactor install scripts and cleanup handling

Replaces manual apt cleanup commands with a unified cleanup_lxc function across install scripts. Updates apt-get to apt for package installation, improves repository setup logic, and standardizes service creation. Minor messaging and variable usage improvements for consistency.
This commit is contained in:
CanbiZ
2025-11-12 11:39:28 +01:00
parent e5c3c19106
commit 5d2d54368a
12 changed files with 48 additions and 88 deletions

View File

@@ -15,8 +15,7 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y git
$STD apt-get install -y sqlite3
$STD apt install -y git sqlite3
msg_ok "Installed Dependencies"
fetch_and_deploy_gh_release "gitea" "go-gitea/gitea" "singlefile" "latest" "/usr/local/bin" "gitea-*-linux-amd64"
@@ -68,8 +67,4 @@ msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -39,8 +39,7 @@ EOF
msg_ok "Configured Glance"
msg_info "Creating Service"
service_path="/etc/systemd/system/glance.service"
echo "[Unit]
cat <<EOF >/etc/systemd/system/glance.service
Description=Glance Daemon
After=network.target
@@ -53,15 +52,11 @@ KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target" >$service_path
WantedBy=multi-user.target
EOF
systemctl enable -q --now glance
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -34,8 +34,4 @@ msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -14,7 +14,7 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y net-tools
$STD apt install -y net-tools
msg_ok "Installed Dependencies"
fetch_and_deploy_gh_release "goaway" "pommee/goaway" "prebuild" "latest" "/opt/goaway" "goaway_*_linux_amd64.tar.gz"
@@ -54,9 +54,4 @@ msg_ok "Service Created"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt -y autoremove
$STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -39,8 +39,4 @@ msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -39,8 +39,4 @@ msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -14,26 +14,25 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
$STD apt install -y \
apt-transport-https \
software-properties-common
msg_ok "Installed Dependencies"
msg_info "Setting up Grafana Repository"
curl -fsSL "https://apt.grafana.com/gpg.key" -o "/usr/share/keyrings/grafana.key"
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" >/etc/apt/sources.list.d/grafana.list
setup_deb822_repo \
"grafana" \
"https://apt.grafana.com/gpg.key" \
"https://apt.grafana.com" \
"stable" \
"main"
msg_ok "Set up Grafana Repository"
msg_info "Installing Grafana"
$STD apt-get update
$STD apt-get install -y grafana
systemctl enable -q --now grafana-server
$STD apt install -y grafana
systemctl enable -q --now grafana-server
msg_ok "Installed Grafana"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -19,17 +19,17 @@ msg_info "Setup Graylog Data Node"
PASSWORD_SECRET=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16)
curl -fsSL "https://packages.graylog2.org/repo/packages/graylog-6.3-repository_latest.deb" -o "graylog-6.3-repository_latest.deb"
$STD dpkg -i graylog-6.3-repository_latest.deb
$STD apt-get update
$STD apt-get install graylog-datanode -y
$STD apt update
$STD apt install graylog-datanode -y
sed -i "s/password_secret =/password_secret = $PASSWORD_SECRET/g" /etc/graylog/datanode/datanode.conf
systemctl enable -q --now graylog-datanode
msg_ok "Setup Graylog Data Node"
msg_info "Setup ${APPLICATION}"
$STD apt-get install graylog-server
msg_info "Setup Graylog"
$STD apt install graylog-server
ROOT_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16)
{
echo "${APPLICATION} Credentials"
echo "Graylog Credentials"
echo "Admin User: admin"
echo "Admin Password: ${ROOT_PASSWORD}"
} >>~/graylog.creds
@@ -38,13 +38,9 @@ sed -i "s/password_secret =/password_secret = $PASSWORD_SECRET/g" /etc/graylog/s
sed -i "s/root_password_sha2 =/root_password_sha2 = $ROOT_PASSWORD/g" /etc/graylog/server/server.conf
sed -i 's/#http_bind_address = 127.0.0.1.*/http_bind_address = 0.0.0.0:9000/g' /etc/graylog/server/server.conf
systemctl enable -q --now graylog-server
msg_ok "Setup ${APPLICATION}"
rm -f graylog-*-repository_latest.deb
msg_ok "Setup Graylog"
motd_ssh
customize
msg_info "Cleaning up"
rm -f graylog-*-repository_latest.deb
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -14,11 +14,12 @@ network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
$STD apt install -y \
make \
ca-certificates \
python3-venv
msg_ok "Installed Dependencies"
NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs
fetch_and_deploy_gh_release "grist" "gristlabs/grist-core" "tarball"
@@ -50,14 +51,9 @@ EnvironmentFile=-/opt/grist/.env
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now grist
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -13,10 +13,6 @@ setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y apt-transport-https
msg_ok "Installed Dependencies"
PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php
fetch_and_deploy_gh_release "grocy" "grocy/grocy" "prebuild" "latest" "/var/www/html" "grocy*.zip"
@@ -47,8 +43,4 @@ msg_ok "Installed grocy"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -20,7 +20,7 @@ msg_ok "Installed Dependencies"
NODE_VERSION="24" setup_nodejs
fetch_and_deploy_gh_release "guardian" "HydroshieldMKII/Guardian" "tarball" "latest" "/opt/guardian"
msg_info "Configuring ${APPLICATION}"
msg_info "Configuring Guardian"
cd /opt/guardian/backend
$STD npm ci
$STD npm run build
@@ -28,7 +28,7 @@ cd /opt/guardian/frontend
$STD npm ci
export DEPLOYMENT_MODE=standalone
$STD npm run build
msg_ok "Configured ${APPLICATION}"
msg_ok "Configured Guardian"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/guardian-backend.service
@@ -60,16 +60,10 @@ RestartSec=3
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now guardian-backend
systemctl enable -q --now guardian-frontend
msg_ok "Created Service"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt -y autoremove
$STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned"
cleanup_lxc

View File

@@ -622,7 +622,8 @@ setup_deb822_repo() {
}
# Create deb822 sources file
cat <<EOF >/etc/apt/sources.list.d/${name}.sources
if [[ -n "$component" ]]; then
cat <<EOF >/etc/apt/sources.list.d/${name}.sources
Types: deb
URIs: $repo_url
Suites: $suite
@@ -630,6 +631,15 @@ Components: $component
Architectures: $architectures
Signed-By: /etc/apt/keyrings/${name}.gpg
EOF
else
cat <<EOF >/etc/apt/sources.list.d/${name}.sources
Types: deb
URIs: $repo_url
Suites: $suite
Architectures: $architectures
Signed-By: /etc/apt/keyrings/${name}.gpg
EOF
fi
# Use cached apt update
local apt_cache_file="/var/cache/apt-update-timestamp"
@@ -1141,7 +1151,7 @@ function fetch_and_deploy_gh_release() {
rm -rf "${target:?}/"*
fi
tar --no-same-owner -xzf "$tmpdir/$filename" -C "$tmpdir" || {
tar --no-same-owner -xzf "$tmpdir/$filename" -C "$tmpdir" || {
msg_error "Failed to extract tarball"
rm -rf "$tmpdir"
return 1