aboutsummaryrefslogtreecommitdiffstats
path: root/karakeep-linux.sh
diff options
context:
space:
mode:
authorChris <punk.sand7393@fastmail.com>2025-05-17 11:06:53 -0400
committerGitHub <noreply@github.com>2025-05-17 16:06:53 +0100
commit4ae5857a40abb66a4cd79d2a07079ad9cef5d01b (patch)
tree13b195fc5b97fe9bad354feadd65c62320dd5a96 /karakeep-linux.sh
parent60f47122b668f4c031871f49a0bbe2260060eeab (diff)
downloadkarakeep-4ae5857a40abb66a4cd79d2a07079ad9cef5d01b.tar.zst
build(Debian): update yt-dlp on karakeep's update and add a service check function (#1329)
* build(Debian): add mcp; yt-dlp update; karakeep service check - Check for yt-dlp update during update process - Karakeep service check function to ensure services are running after install/update/migrate - make status in service_check an array - Bump script version to 2.2
Diffstat (limited to 'karakeep-linux.sh')
-rw-r--r--karakeep-linux.sh51
1 files changed, 39 insertions, 12 deletions
diff --git a/karakeep-linux.sh b/karakeep-linux.sh
index bb7cff8d..ce7fb4d8 100644
--- a/karakeep-linux.sh
+++ b/karakeep-linux.sh
@@ -2,7 +2,7 @@
set -Eeuo pipefail
-# v2.1
+# v2.2
# Copyright 2024-2025
# Author: vhsdream
# Adapted from: The Karakeep installation script from https://github.com/community-scripts/ProxmoxVE
@@ -237,22 +237,18 @@ WantedBy=multi-user.target
EOF
echo "Service files created" && sleep 1
- echo "Enabling and starting services, please wait..." && sleep 3
- systemctl enable -q --now meilisearch.service karakeep.target
- echo "Done" && sleep 1
-
echo "Cleaning up" && sleep 1
rm /tmp/v"$RELEASE".zip
apt -y autoremove
apt -y autoclean
echo "Cleaned" && sleep 1
- echo "OK, Karakeep should be accessible on port 3000 of this device's IP address!" && sleep 4
- exit 0
+ echo "Enabling and starting services, please wait..." && sleep 3
+ systemctl enable -q --now karakeep.target
+ service_check install
}
update() {
- echo "Checking for an update..." && sleep 1
if [[ ! -d ${INSTALL_DIR} ]]; then
echo "Is Karakeep even installed?"
exit 1
@@ -265,6 +261,9 @@ update() {
systemctl stop karakeep-web karakeep-workers
echo "Stopped services" && sleep 1
fi
+ if [[ "$OS" == "bookworm" ]]; then
+ yt-dlp -U
+ fi
echo "Updating Karakeep to v${RELEASE}..." && sleep 1
sed -i "s|SERVER_VERSION=${PREV_RELEASE}|SERVER_VERSION=${RELEASE}|" "$ENV_FILE"
rm -R "$INSTALL_DIR"
@@ -289,10 +288,10 @@ update() {
echo "$RELEASE" >"$INSTALL_DIR"/version.txt
chown -R karakeep:karakeep "$INSTALL_DIR" "$DATA_DIR"
echo "Updated Karakeep to v${RELEASE}" && sleep 1
- echo "Restarting services and cleaning up..." && sleep 1
- systemctl start karakeep-workers karakeep-web
+ echo "Restarting services..." && sleep 1
rm /tmp/v"$RELEASE".zip
- echo "Ready!"
+ systemctl restart karakeep.target
+ service_check update
else
echo "No update required."
fi
@@ -322,13 +321,41 @@ migrate() {
chown -R karakeep:karakeep "$INSTALL_DIR" "$CONFIG_DIR" "$DATA_DIR" "$LOG_DIR"
systemctl daemon-reload
systemctl -q enable --now karakeep.target
- echo "Migration complete!" && sleep 2
+ service_check migrate
else
echo "There is no need for a migration: Karakeep is already installed."
exit 1
fi
}
+service_check() {
+ local services=("karakeep-browser" "karakeep-workers" "karakeep-web")
+ local status=""
+ readarray -t status < <(for service in "${services[@]}"; do
+ systemctl is-active "$service" | grep "^active" -
+ done)
+ if [[ "${#status[@]}" -eq 3 ]]; then
+ if [[ "$1" == "install" ]]; then
+ echo "Karakeep is running!"
+ sleep 1
+ LOCAL_IP="$(hostname -I | awk '{print $1}')"
+ echo "Go to http://$LOCAL_IP:3000 to create your account"
+ exit 0
+ elif [[ "$1" == "update" ]]; then
+ echo "Karakeep is updated and running!"
+ sleep 1
+ exit 0
+ elif [[ "$1" == "migrate" ]]; then
+ echo "Karakeep migration complete!"
+ sleep 1
+ exit 0
+ fi
+ else
+ echo "Some services have failed. Check 'journalctl -xeu <service-name>' to see what is going on"
+ exit 1
+ fi
+}
+
[ "$(id -u)" -ne 0 ] && echo "This script requires root privileges. Please run with sudo or as the root user." && exit 1
command="${1:-}"
if [ "$command" = "" ]; then