systemd user service

This commit is contained in:
Linus Nuber committed 2026-10-20 23:40:58 +02:00
1 parent b6669d0c4c
commit 9ebbf7536d
3 files changed
+36 -41

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Control daemon für browser / keepass Start
After=network.target
[Service]
Type=simple
ExecStart=/sync/data/Linus/scripts/keepassctl
Restart=on-failure
[Install]
WantedBy=default.target
+22 -6
View File
@@ -3,10 +3,26 @@
statedir="/tmp/keepassxc" statedir="/tmp/keepassxc"
fifo="$statedir/fifo" fifo="$statedir/fifo"
#exec 2> "$statedir/error.log" # Client side
#
if [ "$#" -ge 1 ]; then
case "$1" in
keepass)
shift
echo "start-keepass $@" > "$fifo"
;;
browser)
shift
echo "start-browser $@" > "$fifo"
;;
esac
exit 0
fi
# Server side
#
CNTR=0 CNTR=0
RUNTIME=10 # Sekunden RUNTIME=600 # Sekunden
keepass_running() keepass_running()
{ {
@@ -27,14 +43,14 @@ start_keepass()
tick() tick()
{ {
echo "tick" > "$fifo" echo "tick" > "$fifo" &
#echo "tick"
} }
mkdir -p "$statedir" mkdir -p "$statedir"
test -e "$fifo" || mkfifo "$fifo" test -e "$fifo" || mkfifo "$fifo"
exec 2> "$statedir/error.log"
tick & tick
while true; do while true; do
read l < "$fifo" read l < "$fifo"
set -- $l set -- $l
@@ -66,6 +82,6 @@ while true; do
exit 0 exit 0
;; ;;
esac esac
tick & tick
done done
+3 -35
View File
@@ -1,37 +1,5 @@
#!/bin/bash #!/bin/bash
statedir="/tmp/keepassxc" flatpak run org.keepassxc.KeePassXC --pw-stdin --minimized "$@" \
mkdir -p "$statedir" ~/Nextcloud/data/Gemeinsam/keepass/LinusKeyPass.kdbx \
< ~/.local/share/keepass &> /dev/null &
pidfile="$statedir/pid"
keepass_running()
{
test -e "$pidfile" && {
KPID="$(<$pidfile)"
if ps -q "$KPID" >/dev/null 2>&1; then
zenity --info --text "Keepass läuft schon unter pid $KPID"
return 0
fi
rm "$pidfile"
}
return 1
}
start_keepass()
{
if ! keepass_running; then
flatpak run org.keepassxc.KeePassXC --pw-stdin --minimized "$@" \
~/Nextcloud/data/Gemeinsam/keepass/LinusKeyPass.kdbx \
< ~/.local/share/keepass &> /dev/null &
STAT=$?
echo "$!" > "$pidfile"
return $STAT
fi
return 0
}
start_keepass