-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·65 lines (57 loc) · 1.61 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
58
59
60
61
62
63
64
65
#! /bin/bash
_APP_NAME="EasyCoding3"
_CMD_NAME="ec"
_BASHRC="$HOME/.bashrc"
_SCRIPT_PATH=$(readlink -f "$0")
_SCRIPT_DIR=$(dirname ${_SCRIPT_PATH})
_EC_PATH="$_SCRIPT_DIR/launcher.sh"
_NEED_INSTALL="TRUE"
_NEED_UPGRADE="FALSE"
_INSTALL_KEY="alias $_CMD_NAME='source $_EC_PATH'"
_GLOBAL_CONFIG_PATH="$_SCRIPT_DIR/GlobalConfig.py"
_GLOBAL_CONFIG_TEMPLATE_PATH="$_SCRIPT_DIR/cfg/base/GlobalConfig.py"
# start info
echo "Start installing ..."
# check whether need install
while read _LINE; do
if [ "$_LINE" == "$_INSTALL_KEY" ]; then
_NEED_INSTALL="FALSE"
break
fi
done < ${_BASHRC}
# check result
if [ "$_NEED_INSTALL" == "TRUE" ]; then
# install
echo "# Install EasyCoding3" >> ${_BASHRC}
echo "$_INSTALL_KEY" >> ${_BASHRC}
echo "source $_SCRIPT_DIR/auto_complete" >> ${_BASHRC}
echo >> ${_BASHRC}
# success
echo "Installing finished."
echo "Now you can restart your terminal and use $_APP_NAME with command \"$_CMD_NAME\"."
else
# unnecessary to install
echo "Already installed before."
echo "If you still cannot use $_APP_NAME. Please restart your terminal and try again"
fi
# copy GlobalConfig.py if necessary
if [ -e ${_GLOBAL_CONFIG_PATH} ]; then
echo "GlobalConfig.py already exists. Ignore copy"
else
cp -f ${_GLOBAL_CONFIG_TEMPLATE_PATH} ${_GLOBAL_CONFIG_PATH}
fi
# pause
echo "press enter key to exit"
read _PAUSE
# clean up
unset _BASHRC
unset _CMD_NAME
unset _LINE
unset _SCRIPT_PATH
unset _SCRIPT_DIR
unset _EC_PATH
unset _INSTALL_KEY
unset _NEED_INSTALL
unset _GLOBAL_CONFIG_PATH
unset _GLOBAL_CONFIG_TEMPLATE_PATH
unset _GLOBAL_BASH_CONFIG_PATH