-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·74 lines (60 loc) · 1.59 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
usage() {
echo
echo "Usage: install.sh [-u install_user] [-g install_group]"
echo " [-d ONE_LOCATION] [-h]"
echo
echo "-d: target installation directory, if not defined it will be root. Must be"
echo " an absolute path."
echo "-h: prints this help"
}
copy_files() {
FILES=$1
DST=$DESTDIR$2
cp -R src/$1 $DST
if [[ "$ONEADMIN_USER" != "0" || "$ONEADMIN_GROUP" != "0" ]]; then
chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $2
fi
}
ARGS=$*
PARAMETERS="hu:g:d:"
if [ $(getopt --version | tr -d " ") = "--" ]; then
TEMP_OPT=`getopt $PARAMETERS "$@"`
else
TEMP_OPT=`getopt -o $PARAMETERS -n 'install.sh' -- "$@"`
fi
if [ $? != 0 ] ; then
usage
exit 1
fi
eval set -- "$TEMP_OPT"
ONEADMIN_USER=`id -u`
ONEADMIN_GROUP=`id -g`
SRC_DIR=$PWD
while true ; do
case "$1" in
-h) usage; exit 0;;
-d) ROOT="$2" ; shift 2 ;;
-u) ONEADMIN_USER="$2" ; shift 2;;
-g) ONEADMIN_GROUP="$2"; shift 2;;
--) shift ; break ;;
*) usage; exit 1 ;;
esac
done
export ROOT
if [ -z "$ROOT" ]; then
VAR_LOCATION="/var/lib/one"
REMOTES_LOCATION="$VAR_LOCATION/remotes"
ETC_LOCATION="/etc/one"
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
else
VAR_LOCATION="$ROOT/var"
REMOTES_LOCATION="$VAR_LOCATION/remotes"
ETC_LOCATION="$ROOT/etc"
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
fi
mkdir $REMOTES_LOCATION/vmm/oci/
copy_files "im/*" "$REMOTES_LOCATION/im/"
copy_files "vmm/*" "$REMOTES_LOCATION/vmm/oci/"
copy_files "oci_driver.rb" "$RUBY_LIB_LOCATION"
copy_files "etc/*" "$ETC_LOCATION"