-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmachineinstall
More file actions
executable file
·115 lines (102 loc) · 2.33 KB
/
machineinstall
File metadata and controls
executable file
·115 lines (102 loc) · 2.33 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
PROGRAM_NAME=$0
cd `dirname $PROGRAM_NAME`
source machinefunc.sh
function usage()
{
cat << EOF
Usage: $PROGRAM_NAME [arguments]
Arguments:
-h, --help Print Help and exit
-i, --install Perform installation
--reinstall Remove installed parts and perform installation
-c, --clean Remove installed parts
-p, --part=PART Specify a part to install or clean
-l, --list-part List all installable parts
--prefix Set the install path
EOF
}
if [[ "$(whoami)" != "root" ]];then
error "You need to be root to run installation"
exit 1
fi
if [[ $# == 0 ]];then
usage
exit 0
fi
short_opts="hicp:l"
long_opts="help,install,clean,part:,list-part,reinstall,prefix:"
TEMP=$(getopt -n $PROGRAM_NAME -o "$short_opts" -l "$long_opts" -- "$@") || \
{ error "Error parsing arguments. Try $PROGRAM_NAME --help"; exit 1; }
PART="all"
EXE=""
PREFIX=$install_path
eval set -- "$TEMP"
while true; do
case $1 in
-h|--help)
usage
exit 0
;;
-i|--install)
if [[ "$EXE" == "" ]];then
EXE="install"
fi
shift; continue
;;
--reinstall)
if [[ "$EXE" == "" ]];then
EXE="reinstall"
fi
shift; continue
;;
-c|--clean)
if [[ "$EXE" == "" ]];then
EXE="clean"
fi
shift; continue
;;
-p|--part)
PART="$2"; shift 2; continue
;;
-l|--list-part)
if [[ "$EXE" == "" ]];then
EXE="listparts"
fi
shift; continue
;;
--prefix)
PREFIX=$(realpath "$2"); shift 2; continue
;;
--)
# no more arguments to parse
break
;;
*)
error "Unknow option " $1
exit 1
;;
esac
done
export MACHINE_INIT_PREFIX=$PREFIX
export MACHINE_INIT_WORK_DIR=`pwd`
case $EXE in
install)
installParts $PART
;;
reinstall)
cleanParts $PART
installParts $PART
;;
clean)
cleanParts $PART
;;
listparts)
listAllParts
;;
*)
normalp "Nothing has been done"
;;
esac
unset MACHINE_INIT_PREFIX
unset MACHINE_INIT_WORK_DIR