-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·79 lines (67 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
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# This file is part of: nbc (Version 0.1)
# Author: Chiayo Lin
# Date : Nov. 28, 2014
SRC_PATH=./src/
PGM_PATH=/usr/local/bin/
PGM_NAME=nbc
COM_NAME=cc
PGM_XIST=0
COM_XIST=1
# Check if program has been installed
if [ -f $PGM_PATH$PGM_NAME ]; then
PGM_XIST=1
fi
# Check if complier has been installed
command -v $COM_NAME > /dev/null
if [ $? != 0 ]; then
COM_XIST=0
fi
# If program has been installed, ask if user wants to uninstall
if [ $PGM_XIST -eq 1 ]; then
echo "$PGM_NAME already installed on this machine!"
echo -n "Do you want to uninstall it (y/n): "
read INPUT
if [ "$INPUT" == "y" ]; then
echo "rm $PGM_PATH$PGM_NAME..."
rm $PGM_PATH$PGM_NAME
# If there is an error
if [ $? != 0 ]; then
echo "error while removing $PGM_NAME from $PGM_PATH"
else
echo "$PGM_NAME successfully uninstalled :-)"
fi
fi
exit 0
fi
# Exit if a C compiler does not exist on the system
if [ $COM_XIST -eq 0 ]; then
echo "$COM_NAME does not exist, aborting."
exit 1
fi
# Installtion
if [ $PGM_XIST -eq 0 ] && [ $COM_XIST -eq 1 ]; then
oldpwd=$(pwd)
cd $SRC_PATH
make
# If There is an error
if [ $? != 0 ]; then
echo "-------------------------------------"
echo "Whoops, complie error(s), aborting."
echo "please email me with error message(s)"
echo "<chiayo.lin@gmail.com>"
cd ..
exit 1
else
echo "mv $PGM_NAME $PGM_PATH..."
mv $PGM_NAME $PGM_PATH
if [ $? != 0 ]; then
echo "error while moving $PGM_NAME to $PGM_PATH"
cd ..
exit 1
else
echo "$PGM_NAME successfully installed :-)"
fi
fi
fi
cd $oldpath