This repository was archived by the owner on Nov 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall-dev.sh
More file actions
executable file
·93 lines (73 loc) · 2.01 KB
/
install-dev.sh
File metadata and controls
executable file
·93 lines (73 loc) · 2.01 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /bin/bash
set -eu
set -o pipefail
os=$(uname -s | tr '[:upper:]' '[:lower:]')
echo "🚧 Making development build for '$os'..."
make build-${os}
echo "✅ Built"
echo
echo "🚧 Will install the development build"
echo "❗️ The already installed devbookd will be replaced by this build"
devbookd_install="${DEVBOOKD_INSTALL:-$HOME/.devbook}"
bin_dir="$devbookd_install/bin"
exe="$bin_dir/devbookd"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
# Move the dev build to the bin_dir
mv ./bin/darwin/devbookd $exe
cd "$bin_dir"
chmod +x "$exe"
echo "✅ Devbook daemon was installed successfully to $exe"
echo
echo "🚧 Starting Devbook daemon..."
# Find out which user is running the installation.
inst_user=`stat /dev/console | cut -f 5 -d ' '`
service_id="com.devbook.devbookd"
service_file="$HOME/Library/LaunchAgents/${service_id}.plist"
# Cleanup the service from a potential previous installation.
set +e
launchctl unload $service_file > /dev/null 2>&1
killall devbookd > /dev/null 2>&1
if [ -f $service_file ]; then
rm $service_file
fi
set -e
cat << EOF > $service_file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>$service_id</string>
<key>UserName</key>
<string>$inst_user</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>49982</string>
<key>SockType</key>
<string>stream</string>
<key>SockFamily</key>
<string>IPv4</string>
</dict>
<key>StandardErrorPath</key>
<string>/tmp/${service_id}.job.err</string>
<key>StandardOutPath</key>
<string>/tmp/${service_id}.job.out</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>$exe -mode=user</string>
</array>
</dict>
</plist>
EOF
# Start the service
launchctl load $service_file
echo "✅ Devbook daemon is running"