This repository was archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautorun-setup.sh
More file actions
executable file
·67 lines (51 loc) · 1.79 KB
/
Copy pathautorun-setup.sh
File metadata and controls
executable file
·67 lines (51 loc) · 1.79 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
#!/bin/bash
set -e
# if [[ "$0" = "${BASH_SOURCE[0]}" ]]; then
# echo "the script must be runned by source. exit";
# exit 1;
# fi
if ! [ -d ./dist ]; then
echo "dist folder not found! Please build branch-listener.";
return 1
fi
bash ./branch-listener kill "setup"
MAIN_DIR="$HOME/.config/branch-listener"
if [ "$(echo "$SHELL" | grep '/zsh')" ]; then
BRANCH_LISTENER_SHELL_RC="$HOME/.zshrc"
elif [ "$(echo "$SHELL" | grep '/bash')" ]; then
BRANCH_LISTENER_SHELL_RC="$HOME/.bashrc"
else
echo "unsupportable shell! exit"
return 1
fi
if ! [ "$(cat $BRANCH_LISTENER_SHELL_RC | grep BRANCH_LISTENER_SHELL_RC=)" ]; then
echo 'export BRANCH_LISTENER_SHELL_RC='"$BRANCH_LISTENER_SHELL_RC" | tee -a "$BRANCH_LISTENER_SHELL_RC"
fi
if ! [ "$(echo "$PATH" | grep "$MAIN_DIR")" ]; then
export PATH="$PATH":"$MAIN_DIR"
fi
if ! [ "$(cat $BRANCH_LISTENER_SHELL_RC | grep $MAIN_DIR)" ]; then
echo 'export PATH=$PATH:'"$MAIN_DIR" | tee -a "$BRANCH_LISTENER_SHELL_RC"
fi
if [ -z "$BRANCH_LISTENER_MAIN_DIR" ]; then
export BRANCH_LISTENER_MAIN_DIR="$MAIN_DIR"
fi
if ! [ "$(cat $BRANCH_LISTENER_SHELL_RC | grep 'BRANCH_LISTENER_MAIN_DIR='$BRANCH_LISTENER_MAIN_DIR)" ]; then
echo "export BRANCH_LISTENER_MAIN_DIR=$MAIN_DIR" | tee -a "$BRANCH_LISTENER_SHELL_RC"
fi
if [ -d "$MAIN_DIR" ]; then
rm -rf "$MAIN_DIR"
fi
mkdir -p "$MAIN_DIR/dist"
cp -r ./dist/* "$MAIN_DIR/dist"
cp -r ./node_modules "$MAIN_DIR"
cp -r ./assets "$MAIN_DIR"
cp ./branch-listener "$MAIN_DIR"
# if [ -d "./configs" ]; then
# cp -r ./configs "$MAIN_DIR"
# fi
if ! [ "$(cat $BRANCH_LISTENER_SHELL_RC | grep 'branch-listener run')" ]; then
echo 'if [ $TERM = "linux" ]; then branch-listener run; fi' | tee -a "$BRANCH_LISTENER_SHELL_RC"
fi
echo "autorun of branch-listener configured successfully.";
exit 0