-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
55 lines (48 loc) · 1.08 KB
/
install.sh
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
#!/bin/bash
APP_NAME="chatgpt"
INSTALL_DIR="/usr/local/bin"
function show_help()
{
echo "Usage: $0 [-h|--help] [-u|--uninstall]"
echo " -h, --help Show this help message"
echo " -u, --uninstall Uninstall $APP_NAME from the system"
}
function install_app()
{
if [[ -e "$INSTALL_DIR/$APP_NAME" ]]; then
echo "$APP_NAME is already installed in $INSTALL_DIR"
else
sudo cp $APP_NAME $INSTALL_DIR
sudo chmod +x $INSTALL_DIR/$APP_NAME
echo "$APP_NAME has been installed in $INSTALL_DIR"
fi
}
function uninstall_app()
{
if [[ -e "$INSTALL_DIR/$APP_NAME" ]]; then
sudo rm $INSTALL_DIR/$APP_NAME
echo "$APP_NAME has been uninstalled"
else
echo "$APP_NAME is not installed"
fi
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
show_help
exit 0
;;
-u|--uninstall)
uninstall_app
exit 0
;;
*)
echo "Invalid argument: $key"
show_help
exit 1
;;
esac
done
install_app
exit 0