File size: 1,721 Bytes
54656fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# macOS launchd installer for the Sangsangfinder iMessage notification worker.
#
# ์„ค์น˜:  bash scripts/setup_notifications.sh install
# ์ œ๊ฑฐ:  bash scripts/setup_notifications.sh uninstall
# ์ƒํƒœ:  bash scripts/setup_notifications.sh status

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PLIST_NAME="com.sangsangfinder.notifications.plist"
PLIST_SRC="$SCRIPT_DIR/$PLIST_NAME"
AGENTS_DIR="$HOME/Library/LaunchAgents"
PLIST_DST="$AGENTS_DIR/$PLIST_NAME"
LABEL="com.sangsangfinder.notifications"

CMD="${1:-install}"

install() {
    if [ ! -f "$PLIST_SRC" ]; then
        echo "plist ํŒŒ์ผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค: $PLIST_SRC"
        exit 1
    fi

    chmod +x "$SCRIPT_DIR/run_notification_worker.sh"
    mkdir -p "$AGENTS_DIR"
    launchctl unload "$PLIST_DST" 2>/dev/null || true
    cp "$PLIST_SRC" "$PLIST_DST"
    launchctl load "$PLIST_DST"

    echo "์•Œ๋ฆผ ์›Œ์ปค ์„ค์น˜ ์™„๋ฃŒ"
    echo "  ์ƒํƒœ ํ™•์ธ: launchctl list | grep $LABEL"
    echo "  ๋กœ๊ทธ ํ™•์ธ: tail -f $SCRIPT_DIR/notice_notification_worker.log"
    echo "  ์ œ๊ฑฐ: bash $SCRIPT_DIR/setup_notifications.sh uninstall"
}

uninstall() {
    launchctl unload "$PLIST_DST" 2>/dev/null || true
    rm -f "$PLIST_DST"
    echo "์•Œ๋ฆผ ์›Œ์ปค ์ œ๊ฑฐ ์™„๋ฃŒ"
}

status() {
    echo "=== launchd ์ƒํƒœ ==="
    launchctl list | grep "$LABEL" || echo "๋“ฑ๋ก๋œ job ์—†์Œ"
    echo ""
    echo "=== ์ตœ๊ทผ ๋กœ๊ทธ ==="
    tail -20 "$SCRIPT_DIR/notice_notification_worker.log" 2>/dev/null || echo "๋กœ๊ทธ ํŒŒ์ผ ์—†์Œ"
}

case "$CMD" in
    install) install ;;
    uninstall) uninstall ;;
    status) status ;;
    *)
        echo "์‚ฌ์šฉ๋ฒ•: $0 {install|uninstall|status}"
        exit 1
        ;;
esac