-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·57 lines (46 loc) · 1.59 KB
/
install
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
#!/bin/bash
# Set the path to the JAR file and the target directory
JAR_PATH=~/Library/Java/Extensions/wk.jar
MAN_PATH=~/.local/share/man
BIN_PATH=~/bin
# Build the project and check the exit code
if ! ./gradlew build; then
echo "Error: Gradle build failed."
echo "Installation aborted."
exit 1
fi
# Move the JAR file to the target directory
mkdir -p ~/Library/Java/Extensions
chmod +x build/libs/wk-1.0.0.jar
mv build/libs/wk-1.0.0.jar "$JAR_PATH"
# Create the wk script
echo '#!/bin/bash' > wk
echo "java -jar $JAR_PATH \"\$@\"" >> wk
chmod +x wk
# Move the script to the bin directory
mkdir -p "$BIN_PATH"
mv wk "$BIN_PATH/wk"
# Copy the man page to the local man directory
mkdir -p "$MAN_PATH/man1"
cp wk.1 "$MAN_PATH/man1/"
# Update ~/.profile only if the export PATH line doesn't exist
if ! grep -q "export PATH=\"\$PATH:$BIN_PATH\"" ~/.profile; then
echo '# Add /bin to the PATH' >> ~/.profile
echo "export PATH=\"\$PATH:$BIN_PATH\"" >> ~/.profile
fi
# Update ~/.profile to include the local man directory in MANPATH
if ! grep -q "export MANPATH=\"\$MANPATH:$MAN_PATH\"" ~/.profile; then
echo '# Add local man directory to MANPATH' >> ~/.profile
echo "export MANPATH=\"\$MANPATH:$MAN_PATH\"" >> ~/.profile
fi
# Source the configuration file
PROFILE_PATH=~/.profile
if ! grep -q "export PATH=\"\$PATH:$BIN_PATH\"" "$PROFILE_PATH"; then
echo '# Add /bin to the PATH' >> "$PROFILE_PATH"
echo "export PATH=\"\$PATH:$BIN_PATH\"" >> "$PROFILE_PATH"
fi
# Source the configuration file with a directive
# shellcheck source=/dev/null
source "$PROFILE_PATH"
echo "Installation successful."
echo "$> man wk"