forked from OpenNebula/addon-appmarket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·157 lines (128 loc) · 4.11 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
ARGS=$*
usage() {
echo
echo "Usage: install.sh [-u install_user] [-g install_group]"
echo " [-d ONE_LOCATION] [-l] [-h]"
echo
echo "-d: target installation directory, if not defined it'd be root. Must be"
echo " an absolute path. Installation will be selfcontained"
echo "-l: creates symlinks instead of copying files, useful for development"
echo "-h: prints this help"
}
PARAMETERS="hlu: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"
LINK="no"
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 ;;
-l) LINK="yes" ; shift ;;
-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
LIB_LOCATION="/usr/lib/one/ruby/oneapps"
BIN_LOCATION="/usr/bin"
PACKAGES_LOCATION="/usr/share/one/oneapps"
SHARE_LOCATION="/usr/share/one/oneapps"
ETC_LOCATION="/etc/one"
SUNSTONE_LOCATION="/usr/lib/one/sunstone"
else
LIB_LOCATION="$ROOT/lib/ruby/oneapps"
BIN_LOCATION="$ROOT/bin"
PACKAGES_LOCATION="$ROOT/share/oneapps"
SHARE_LOCATION="$ROOT/share/oneapps"
ETC_LOCATION="$ROOT/etc"
SUNSTONE_LOCATION="$ROOT/lib/sunstone"
fi
do_file() {
if [ "$UNINSTALL" = "yes" ]; then
rm $2/`basename $1`
else
if [ "$LINK" = "yes" ]; then
ln -fs $SRC_DIR/$1 $2
else
cp -R $SRC_DIR/$1 $2
fi
fi
}
copy_files() {
FILES=$1
DST=$DESTDIR$2
mkdir -p $DST
for f in $FILES; do
do_file src/$f $DST
done
}
create_dirs() {
DIRS=$*
for d in $DIRS; do
dir=$DESTDIR$d
mkdir -p $dir
done
}
change_ownership() {
DIRS=$*
for d in $DIRS; do
chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d
done
}
(
cd src
## Client files
copy_files "client/lib/*" "$LIB_LOCATION/market"
copy_files "client/bin/*" "$BIN_LOCATION"
## Server files
# bin
copy_files "bin/*" "$BIN_LOCATION"
# dirs containing files
copy_files "controllers models public views" "$LIB_LOCATION/market"
# files
copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \
Rakefile config/init.rb" "$LIB_LOCATION/market"
# Sunstone
copy_files "sunstone/public/js/*" "$SUNSTONE_LOCATION/public/js/plugins"
copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images"
copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes"
# version
copy_files "version.rb" "$LIB_LOCATION"
# Do not link the ETC files
LINK="no"
copy_files "sunstone/etc/sunstone-appmarket.conf" "$ETC_LOCATION"
copy_files "config/appmarket-server.conf" "$ETC_LOCATION"
)
if [ -z "$NOPOSTINSTALL" ]; then
./postinstall
fi