Refactor: Gotify (#6301)
* Refactor Gotify * Add tools.func fix * Update gotify.sh
This commit is contained in:
parent
1f1bc5f12d
commit
69e947246a
13
ct/gotify.sh
13
ct/gotify.sh
@ -29,23 +29,18 @@ function update_script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/gotify/server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
RELEASE=$(curl -fsSL https://api.github.com/repos/gotify/server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
if [[ "${RELEASE}" != "$(cat ~/.gotify 2>/dev/null)" ]] || [[ ! -f ~/.gotify ]]; then
|
||||||
msg_info "Stopping ${APP}"
|
msg_info "Stopping ${APP}"
|
||||||
systemctl stop gotify
|
systemctl stop gotify
|
||||||
msg_ok "Stopped ${APP}"
|
msg_ok "Stopped ${APP}"
|
||||||
|
|
||||||
msg_info "Updating ${APP} to ${RELEASE}"
|
fetch_and_deploy_gh_release "gotify" "gotify/server" "prebuild" "latest" "/opt/gotify" "gotify-linux-amd64.zip"
|
||||||
cd /opt/gotify
|
chmod +x /opt/gotify/gotify-linux-amd64
|
||||||
curl -fsSL "https://github.com/gotify/server/releases/download/v${RELEASE}/gotify-linux-amd64.zip" -o $(basename "https://github.com/gotify/server/releases/download/v${RELEASE}/gotify-linux-amd64.zip")
|
|
||||||
$STD unzip -o gotify-linux-amd64.zip
|
|
||||||
rm -rf gotify-linux-amd64.zip
|
|
||||||
chmod +x gotify-linux-amd64
|
|
||||||
echo "${RELEASE}" >/opt/${APP}_version.txt
|
|
||||||
msg_ok "Updated ${APP} to ${RELEASE}"
|
|
||||||
|
|
||||||
msg_info "Starting ${APP}"
|
msg_info "Starting ${APP}"
|
||||||
systemctl start gotify
|
systemctl start gotify
|
||||||
msg_ok "Started ${APP}"
|
msg_ok "Started ${APP}"
|
||||||
|
|
||||||
msg_ok "Updated Successfully"
|
msg_ok "Updated Successfully"
|
||||||
else
|
else
|
||||||
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
msg_ok "No update required. ${APP} is already at ${RELEASE}"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
],
|
],
|
||||||
"date_created": "2024-05-02",
|
"date_created": "2024-05-02",
|
||||||
"type": "ct",
|
"type": "ct",
|
||||||
"updateable": false,
|
"updateable": true,
|
||||||
"privileged": false,
|
"privileged": false,
|
||||||
"interface_port": 80,
|
"interface_port": 80,
|
||||||
"documentation": "https://gotify.net/docs/index",
|
"documentation": "https://gotify.net/docs/index",
|
||||||
|
@ -13,16 +13,8 @@ setting_up_container
|
|||||||
network_check
|
network_check
|
||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Gotify"
|
fetch_and_deploy_gh_release "gotify" "gotify/server" "prebuild" "latest" "/opt/gotify" "gotify-linux-amd64.zip"
|
||||||
RELEASE=$(curl -fsSL https://api.github.com/repos/gotify/server/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
chmod +x /opt/gotify/gotify-linux-amd64
|
||||||
mkdir -p /opt/gotify
|
|
||||||
cd /opt/gotify
|
|
||||||
curl -fsSL "https://github.com/gotify/server/releases/download/v${RELEASE}/gotify-linux-amd64.zip" -o "gotify-linux-amd64.zip"
|
|
||||||
$STD unzip gotify-linux-amd64.zip
|
|
||||||
rm -rf gotify-linux-amd64.zip
|
|
||||||
chmod +x gotify-linux-amd64
|
|
||||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
|
||||||
msg_ok "Installed Gotify"
|
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
cat <<EOF >/etc/systemd/system/gotify.service
|
cat <<EOF >/etc/systemd/system/gotify.service
|
||||||
|
@ -959,7 +959,7 @@ function fetch_and_deploy_gh_release() {
|
|||||||
$STD apt-get install -y unzip
|
$STD apt-get install -y unzip
|
||||||
fi
|
fi
|
||||||
unzip -q "$tmpdir/$filename" -d "$unpack_tmp"
|
unzip -q "$tmpdir/$filename" -d "$unpack_tmp"
|
||||||
elif [[ "$filename" == *.tar.* ]]; then
|
elif [[ "$filename" == *.tar.* || "$filename" == *.tgz ]]; then
|
||||||
tar -xf "$tmpdir/$filename" -C "$unpack_tmp"
|
tar -xf "$tmpdir/$filename" -C "$unpack_tmp"
|
||||||
else
|
else
|
||||||
msg_error "Unsupported archive format: $filename"
|
msg_error "Unsupported archive format: $filename"
|
||||||
@ -969,23 +969,41 @@ function fetch_and_deploy_gh_release() {
|
|||||||
|
|
||||||
local top_dirs
|
local top_dirs
|
||||||
top_dirs=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d | wc -l)
|
top_dirs=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d | wc -l)
|
||||||
|
local top_entries inner_dir
|
||||||
if [[ "$top_dirs" -eq 1 ]]; then
|
top_entries=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1)
|
||||||
|
if [[ "$(echo "$top_entries" | wc -l)" -eq 1 && -d "$top_entries" ]]; then
|
||||||
# Strip leading folder
|
# Strip leading folder
|
||||||
local inner_dir
|
inner_dir="$top_entries"
|
||||||
inner_dir=$(find "$unpack_tmp" -mindepth 1 -maxdepth 1 -type d)
|
|
||||||
shopt -s dotglob nullglob
|
shopt -s dotglob nullglob
|
||||||
cp -r "$inner_dir"/* "$target/"
|
if compgen -G "$inner_dir/*" >/dev/null; then
|
||||||
|
cp -r "$inner_dir"/* "$target/" || {
|
||||||
|
msg_error "Failed to copy contents from $inner_dir to $target"
|
||||||
|
rm -rf "$tmpdir" "$unpack_tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg_error "Inner directory is empty: $inner_dir"
|
||||||
|
rm -rf "$tmpdir" "$unpack_tmp"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
shopt -u dotglob nullglob
|
shopt -u dotglob nullglob
|
||||||
else
|
else
|
||||||
# Copy all contents
|
# Copy all contents
|
||||||
shopt -s dotglob nullglob
|
shopt -s dotglob nullglob
|
||||||
cp -r "$unpack_tmp"/* "$target/"
|
if compgen -G "$unpack_tmp/*" >/dev/null; then
|
||||||
|
cp -r "$unpack_tmp"/* "$target/" || {
|
||||||
|
msg_error "Failed to copy contents to $target"
|
||||||
|
rm -rf "$tmpdir" "$unpack_tmp"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg_error "Unpacked archive is empty"
|
||||||
|
rm -rf "$tmpdir" "$unpack_tmp"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
shopt -u dotglob nullglob
|
shopt -u dotglob nullglob
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$unpack_tmp"
|
|
||||||
|
|
||||||
### Singlefile Mode ###
|
### Singlefile Mode ###
|
||||||
elif [[ "$mode" == "singlefile" ]]; then
|
elif [[ "$mode" == "singlefile" ]]; then
|
||||||
local pattern="${6%\"}"
|
local pattern="${6%\"}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user