Refactor: Kavita + Updated tools.func (no-same-owner) (#8594)

This commit is contained in:
CanbiZ
2025-10-23 06:46:28 -07:00
committed by GitHub
parent 05fd03d160
commit 1fe00c2493
4 changed files with 36 additions and 33 deletions

View File

@@ -11,7 +11,7 @@ var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}" var_ram="${var_ram:-2048}"
var_disk="${var_disk:-8}" var_disk="${var_disk:-8}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-12}" var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}" var_unprivileged="${var_unprivileged:-1}"
header_info "$APP" header_info "$APP"
@@ -20,23 +20,28 @@ color
catch_errors catch_errors
function update_script() { function update_script() {
header_info header_info
check_container_storage check_container_storage
check_container_resources check_container_resources
if [[ ! -d /opt/Kavita ]]; then if [[ ! -d /opt/Kavita ]]; then
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Updating $APP LXC"
systemctl stop kavita
RELEASE=$(curl -fsSL https://api.github.com/repos/Kareadita/Kavita/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
$STD tar -xvzf <(curl -fsSL https://github.com/Kareadita/Kavita/releases/download/$RELEASE/kavita-linux-x64.tar.gz) --no-same-owner
rm -rf Kavita/config
cp -r Kavita/* /opt/Kavita
rm -rf Kavita
systemctl start kavita
msg_ok "Updated $APP LXC"
exit exit
fi
if check_for_gh_release "kavita" "Kareadita/Kavita"; then
msg_info "Stopping Service"
systemctl stop kavita
msg_ok "Service Stopped"
fetch_and_deploy_gh_release "kavita" "Kareadita/Kavita" "prebuild" "latest" "/opt/Kavita" "kavita-linux-x64.tar.gz"
chmod +x /opt/Kavita/Kavita && chown root:root /opt/Kavita/Kavita
msg_info "Starting Service"
systemctl start kavita
msg_ok "Service Started"
msg_ok "Update Successfully!"
fi
exit
} }
start start
@@ -46,4 +51,4 @@ description
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5000${CL}" echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:5000${CL}"

View File

@@ -23,7 +23,7 @@
"ram": 2048, "ram": 2048,
"hdd": 8, "hdd": 8,
"os": "debian", "os": "debian",
"version": "12" "version": "13"
} }
} }
], ],

View File

@@ -13,15 +13,11 @@ setting_up_container
network_check network_check
update_os update_os
msg_info "Installing Kavita" fetch_and_deploy_gh_release "Kavita" "Kareadita/Kavita" "prebuild" "latest" "/opt/Kavita" "kavita-linux-x64.tar.gz"
cd /opt
RELEASE=$(curl -fsSL https://api.github.com/repos/Kareadita/Kavita/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
$STD tar -xvzf <(curl -fsSL https://github.com/Kareadita/Kavita/releases/download/$RELEASE/kavita-linux-x64.tar.gz) --no-same-owner
msg_ok "Installed Kavita"
msg_info "Creating Service" msg_info "Creating Service"
service_path="/etc/systemd/system/kavita.service" cat <<EOF >/etc/systemd/system/kavita.service
echo "[Unit] [Unit]
Description=Kavita Server Description=Kavita Server
After=network.target After=network.target
@@ -34,15 +30,17 @@ KillMode=process
Restart=on-failure Restart=on-failure
[Install] [Install]
WantedBy=multi-user.target" >$service_path WantedBy=multi-user.target
chmod +x /opt/Kavita/* && chown root /opt/Kavita/* EOF
systemctl enable --now -q kavita.service chmod +x /opt/Kavita/Kavita && chown root:root /opt/Kavita/Kavita
systemctl enable -q --now kavita
msg_ok "Created Service" msg_ok "Created Service"
motd_ssh motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt-get -y autoremove $STD apt -y autoremove
$STD apt-get -y autoclean $STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned" msg_ok "Cleaned"

View File

@@ -1141,7 +1141,7 @@ function fetch_and_deploy_gh_release() {
rm -rf "${target:?}/"* rm -rf "${target:?}/"*
fi fi
tar -xzf "$tmpdir/$filename" -C "$tmpdir" || { tar --no-same-owner -xzf "$tmpdir/$filename" -C "$tmpdir" || {
msg_error "Failed to extract tarball" msg_error "Failed to extract tarball"
rm -rf "$tmpdir" rm -rf "$tmpdir"
return 1 return 1
@@ -1263,7 +1263,7 @@ function fetch_and_deploy_gh_release() {
return 1 return 1
} }
elif [[ "$filename" == *.tar.* || "$filename" == *.tgz ]]; then elif [[ "$filename" == *.tar.* || "$filename" == *.tgz ]]; then
tar -xf "$tmpdir/$filename" -C "$unpack_tmp" || { tar --no-same-owner -xf "$tmpdir/$filename" -C "$unpack_tmp" || {
msg_error "Failed to extract TAR archive" msg_error "Failed to extract TAR archive"
rm -rf "$tmpdir" "$unpack_tmp" rm -rf "$tmpdir" "$unpack_tmp"
return 1 return 1