1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

M #~: Add FireEdge to install.sh (#70)

This commit is contained in:
Sergio Betanzos 2020-07-02 16:12:39 +02:00 committed by GitHub
parent d928bf5812
commit 32544741a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 302 additions and 9 deletions

View File

@ -201,6 +201,9 @@ main_env.Append(enterprise=ARGUMENTS.get('enterprise', 'no'))
# Sunstone minified files generation
main_env.Append(sunstone=ARGUMENTS.get('sunstone', 'no'))
# FireEdge minified files generation
main_env.Append(fireedge=ARGUMENTS.get('fireedge', 'no'))
# TODO this should be aligned with one-ee-tools workflows
# Onedb Marshal files generation
main_env.Append(marshal=ARGUMENTS.get('marshal', 'no'))
@ -309,6 +312,7 @@ build_scripts = [
'src/ipamm/SConstruct',
'src/sunstone/public/locale/languages/SConstruct',
'src/sunstone/public/SConstruct',
'src/fireedge/SConstruct',
'share/rubygems/SConstruct',
'src/client/SConstruct',
'src/docker_machine/SConstruct',

View File

@ -43,6 +43,8 @@ usage() {
echo "-c: install client utilities: OpenNebula cli and ec2 client files"
echo "-s: install OpenNebula Sunstone"
echo "-p: do not install OpenNebula Sunstone non-minified files"
echo "-F: install OpenNebula FireEdge"
echo "-P: do not install OpenNebula FireEdge non-minified files"
echo "-G: install only OpenNebula Gate"
echo "-f: install only OpenNebula Flow"
echo "-r: remove Opennebula, only useful if -d was not specified, otherwise"
@ -53,7 +55,7 @@ usage() {
}
#-------------------------------------------------------------------------------
PARAMETERS=":u:g:d:ehkrlcsporlfG"
PARAMETERS=":u:g:d:ehkrlcspFPorlfG"
INSTALL_ETC="yes"
UNINSTALL="no"
@ -62,6 +64,8 @@ CLIENT="no"
ONEGATE="no"
SUNSTONE="no"
SUNSTONE_DEV="yes"
FIREEDGE="no"
FIREEDGE_DEV="yes"
ONEFLOW="no"
ONEADMIN_USER=`id -u`
ONEADMIN_GROUP=`id -g`
@ -79,6 +83,8 @@ while getopts $PARAMETERS opt; do
G) ONEGATE="yes" ;;
s) SUNSTONE="yes" ;;
p) SUNSTONE_DEV="no" ;;
F) FIREEDGE="yes" ;;
P) FIREEDGE_DEV="no" ;;
f) ONEFLOW="yes" ;;
u) ONEADMIN_USER="$OPTARG" ;;
g) ONEADMIN_GROUP="$OPTARG" ;;
@ -104,6 +110,7 @@ if [ -z "$ROOT" ] ; then
VAR_LOCATION="/var/lib/one"
ONEGATE_LOCATION="$LIB_LOCATION/onegate"
SUNSTONE_LOCATION="$LIB_LOCATION/sunstone"
FIREEDGE_LOCATION="$LIB_LOCATION/fireedge"
ONEFLOW_LOCATION="$LIB_LOCATION/oneflow"
ONEHEM_LOCATION="$LIB_LOCATION/onehem"
SYSTEM_DS_LOCATION="$VAR_LOCATION/datastores/0"
@ -115,7 +122,7 @@ if [ -z "$ROOT" ] ; then
MAN_LOCATION="/usr/share/man/man1"
VM_LOCATION="/var/lib/one/vms"
DOCS_LOCATION="/usr/share/doc/one"
MAIN_JS_LOCATION="$VAR_LOCATION/sunstone"
SUNSTONE_MAIN_JS_LOCATION="$VAR_LOCATION/sunstone"
DOCKER_MACHINE_LOCATION="src/docker_machine/src/docker_machine/bin/docker-machine-driver-opennebula"
if [ "$CLIENT" = "yes" ]; then
@ -126,7 +133,14 @@ if [ -z "$ROOT" ] ; then
CHOWN_DIRS=""
elif [ "$SUNSTONE" = "yes" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION \
$SUNSTONE_LOCATION $ETC_LOCATION $MAIN_JS_LOCATION"
$SUNSTONE_LOCATION $ETC_LOCATION $SUNSTONE_MAIN_JS_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
CHOWN_DIRS=""
elif [ "$FIREEDGE" = "yes" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION \
$ETC_LOCATION $FIREEDGE_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
@ -157,7 +171,7 @@ if [ -z "$ROOT" ] ; then
$LOG_LOCATION $RUN_LOCATION $LOCK_LOCATION \
$SYSTEM_DS_LOCATION $DEFAULT_DS_LOCATION $MAN_LOCATION \
$VM_LOCATION $ONEGATE_LOCATION $ONEFLOW_LOCATION \
$MAIN_JS_LOCATION $ONEHEM_LOCATION"
$SUNSTONE_MAIN_JS_LOCATION $ONEHEM_LOCATION"
DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \
$RUN_LOCATION $SHARE_DIRS"
@ -175,6 +189,7 @@ else
LOCK_LOCATION="$VAR_LOCATION/lock"
ONEGATE_LOCATION="$LIB_LOCATION/onegate"
SUNSTONE_LOCATION="$LIB_LOCATION/sunstone"
FIREEDGE_LOCATION="$LIB_LOCATION/fireedge"
ONEFLOW_LOCATION="$LIB_LOCATION/oneflow"
ONEHEM_LOCATION="$LIB_LOCATION/onehem"
SYSTEM_DS_LOCATION="$VAR_LOCATION/datastores/0"
@ -184,7 +199,7 @@ else
MAN_LOCATION="$ROOT/share/man/man1"
VM_LOCATION="$VAR_LOCATION/vms"
DOCS_LOCATION="$ROOT/share/doc"
MAIN_JS_LOCATION="$VAR_LOCATION/sunstone"
SUNSTONE_MAIN_JS_LOCATION="$VAR_LOCATION/sunstone"
DOCKER_MACHINE_LOCATION="src/docker_machine/src/docker_machine/bin/docker-machine-driver-opennebula"
if [ "$CLIENT" = "yes" ]; then
@ -198,7 +213,12 @@ else
DELETE_DIRS="$MAKE_DIRS"
elif [ "$SUNSTONE" = "yes" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION \
$SUNSTONE_LOCATION $ETC_LOCATION $MAIN_JS_LOCATION"
$SUNSTONE_LOCATION $ETC_LOCATION $SUNSTONE_MAIN_JS_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
elif [ "$FIREEDGE" = "yes" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION \
$FIREEDGE_LOCATION $ETC_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
elif [ "$ONEFLOW" = "yes" ]; then
@ -215,7 +235,7 @@ else
$INCLUDE_LOCATION $SHARE_LOCATION $SYSTEM_DS_LOCATION \
$DEFAULT_DS_LOCATION $MAN_LOCATION $DOCS_LOCATION \
$VM_LOCATION $ONEGATE_LOCATION $ONEFLOW_LOCATION \
$MAIN_JS_LOCATION $ONEHEM_LOCATION $LOCK_LOCATION $RUN_LOCATION"
$SUNSTONE_MAIN_JS_LOCATION $ONEHEM_LOCATION $LOCK_LOCATION $RUN_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
@ -453,6 +473,8 @@ SUNSTONE_MINIFIED_DIRS="$SUNSTONE_LOCATION/public \
$SUNSTONE_LOCATION/public/images \
$SUNSTONE_LOCATION/public/images/logos"
FIREEDGE_DIRS="$FIREEDGE_LOCATION"
ONEFLOW_DIRS="$ONEFLOW_LOCATION/lib \
$ONEFLOW_LOCATION/lib/strategy \
$ONEFLOW_LOCATION/lib/models"
@ -489,7 +511,7 @@ elif [ "$SUNSTONE_DEV" = "no" ]; then
$SUNSTONE_DIRS $SUNSTONE_MINIFIED_DIRS $ONEFLOW_DIRS"
else
MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS $VAR_DIRS \
$SUNSTONE_DIRS $ONEFLOW_DIRS"
$SUNSTONE_DIRS $FIREEDGE_DIRS $ONEFLOW_DIRS"
fi
#-------------------------------------------------------------------------------
@ -752,6 +774,15 @@ INSTALL_SUNSTONE_ETC_FILES=(
SUNSTONE_ETC_VIEW_MIXED:$ETC_LOCATION/sunstone-views/mixed
)
INSTALL_FIREEDGE_MINIFIED_DIRS=(
FIREEDGE_MINIFIED_FILES:$FIREEDGE_LOCATION
FIREEDGE_BIN_FILES:$BIN_LOCATION
)
INSTALL_FIREEDGE_DEV_DIRS=(
FIREEDGE_DEV_FILES:$FIREEDGE_LOCATION
)
INSTALL_ONEGATE_FILES=(
ONEGATE_FILES:$ONEGATE_LOCATION
ONEGATE_BIN_FILES:$BIN_LOCATION
@ -2537,6 +2568,20 @@ SUNSTONE_PUBLIC_LOCALE_TR_TR="\
src/sunstone/public/locale/languages/tr_TR.js \
src/sunstone/public/locale/languages/tr_datatable.txt"
#-----------------------------------------------------------------------------
# FireEdge files
#-----------------------------------------------------------------------------
FIREEDGE_BIN_FILES="src/fireedge/bin/fireedge-server"
FIREEDGE_MINIFIED_FILES="src/fireedge/dist"
FIREEDGE_DEV_FILES="src/fireedge/src \
src/fireedge/webpack.config.js \
src/fireedge/copyStaticAssets.js \
src/fireedge/package.json \
src/fireedge/config.yaml"
#-----------------------------------------------------------------------------
# OneGate files
#-----------------------------------------------------------------------------
@ -2714,7 +2759,6 @@ do_file() {
fi
}
if [ "$CLIENT" = "yes" ]; then
INSTALL_SET=${INSTALL_CLIENT_FILES[@]}
elif [ "$ONEGATE" = "yes" ]; then
@ -2729,6 +2773,13 @@ elif [ "$SUNSTONE" = "yes" ]; then
${INSTALL_SUNSTONE_PUBLIC_DEV_DIR[@]}
${INSTALL_SUNSTONE_FILES[@]}"
fi
elif [ "$FIREEDGE" = "yes" ]; then
if [ "$FIREEDGE_DEV" = "no" ]; then
INSTALL_SET="${INSTALL_FIREEDGE_MINIFIED_DIRS[@]}"
else
INSTALL_SET="${INSTALL_FIREEDGE_DEV_DIRS[@]} \
${INSTALL_FIREEDGE_MINIFIED_DIRS[@]}"
fi
elif [ "$ONEFLOW" = "yes" ]; then
INSTALL_SET="${INSTALL_ONEFLOW_FILES[@]}"
elif [ "$DOCKER_MACHINE" = "yes" ]; then
@ -2740,9 +2791,17 @@ elif [ "$SUNSTONE_DEV" = "no" ]; then
${INSTALL_ONEFLOW_FILES[@]} \
${INSTALL_ONEHEM_FILES[@]} \
${INSTALL_ONEPROVISION_FILES[@]}"
elif [ "$FIREEDGE_DEV" = "no" ]; then
INSTALL_SET="${INSTALL_FILES[@]} \
${INSTALL_FIREEDGE_MINIFIED_DIRS[@]}\
${INSTALL_ONEGATE_FILES[@]} \
${INSTALL_ONEFLOW_FILES[@]} \
${INSTALL_ONEHEM_FILES[@]} \
${INSTALL_ONEPROVISION_FILES[@]}"
else
INSTALL_SET="${INSTALL_FILES[@]} \
${INSTALL_SUNSTONE_FILES[@]} ${INSTALL_SUNSTONE_PUBLIC_DEV_DIR[@]}\
${INSTALL_FIREEDGE_MINIFIED_DIRS[@]} ${INSTALL_FIREEDGE_DEV_DIRS[@]}\
${INSTALL_ONEGATE_FILES[@]} \
${INSTALL_ONEFLOW_FILES[@]} \
${INSTALL_ONEHEM_FILES[@]} \

35
src/fireedge/SConstruct Normal file
View File

@ -0,0 +1,35 @@
# SConstruct for share/man
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
# #
# 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. #
#--------------------------------------------------------------------------- #
import os
Import('env')
if env['fireedge']=='yes':
print ("Generating FireEdge minified files\n")
if env['enterprise']=='yes':
print("OpenNebula Enterprise FireEdge\n")
exit_code=os.system("./build.sh -e")
else:
exit_code=os.system("./build.sh")
if exit_code != 0:
print ("Error generating minifying FireEdge files\n")
exit(-1)

119
src/fireedge/bin/fireedge-server Executable file
View File

@ -0,0 +1,119 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
# #
# 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. #
#--------------------------------------------------------------------------- #
if [ -z "$ONE_LOCATION" ]; then
FIREEDGE_PID=/var/run/one/fireedge.pid
FIREEDGE_SERVER=/usr/lib/one/fireedge/dist/index.js
FIREEDGE_LOCK_FILE=/var/lock/one/.fireedge.lock
FIREEDGE_LOG=/var/log/one/fireedge.log
FIREEDGE_LOG_ERROR=/var/log/one/fireedge.error
else
FIREEDGE_PID=$ONE_LOCATION/var/fireedge.pid
FIREEDGE_SERVER=$ONE_LOCATION/lib/fireedge/dist/index.js
FIREEDGE_LOCK_FILE=$ONE_LOCATION/var/.fireedge.lock
FIREEDGE_LOG=$ONE_LOCATION/var/fireedge.log
FIREEDGE_LOG_ERROR=$ONE_LOCATION/var/fireedge.error
fi
setup()
{
if [ -f $FIREEDGE_LOCK_FILE ]; then
if [ -f $FIREEDGE_PID ]; then
FIREEDGEPID=`cat $FIREEDGE_PID`
ps $FIREEDGEPID > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "FireEdge Server is still running (PID:$FIREEDGEPID)."
echo "Please try 'fireedge-server stop' first."
exit 1
fi
fi
echo "Stale .lock detected. Erasing it."
rm $FIREEDGE_LOCK_FILE
fi
}
start()
{
if [ ! -f "$FIREEDGE_SERVER" ]; then
echo "Cannot find $FIREEDGE_SERVER."
exit 1
fi
touch $FIREEDGE_LOCK_FILE
# Start the oneflow-server daemon
node $FIREEDGE_SERVER >$FIREEDGE_LOG 2>$FIREEDGE_LOG_ERROR &
LASTRC=$?
LASTPID=$!
if [ $LASTRC -ne 0 ]; then
echo "Error executing fireedge-server."
echo "Check $FIREEDGE_LOG_ERROR and $FIREEDGE_LOG for more information"
exit 1
else
echo $LASTPID > $FIREEDGE_PID
fi
sleep 2
ps $LASTPID > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error executing fireedge-server."
echo "Check $FIREEDGE_LOG_ERROR and $FIREEDGE_LOG for more information"
exit 1
fi
}
stop()
{
if [ ! -f $FIREEDGE_PID ]; then
echo "Couldn't find fireedge-server process pid."
exit 1
fi
# Kill the fireedge-server daemon
kill -INT `cat $FIREEDGE_PID` > /dev/null 2>&1
# Remove pid files
rm -f $FIREEDGE_PID > /dev/null 2>&1
rm -f $FIREEDGE_LOCK_FILE &> /dev/null
}
case "$1" in
start)
setup
start
echo "fireedge-server started"
;;
stop)
stop
echo "fireedge-server stopped"
;;
restart)
stop 2> /dev/null
setup
start
echo "fireedge-server restarted"
;;
*)
echo "Usage: fireedge-server {start|stop|restart}" >&2
exit 3
;;
esac

76
src/fireedge/build.sh Executable file
View File

@ -0,0 +1,76 @@
#!/bin/bash
set -e
#-------------------------------------------------------------------------------
usage() {
echo
echo "Usage: build.sh [-d] [-c] [-l] [-h] [-e]"
echo
echo "-d: install build dependencies"
echo "-c: clean build"
echo "-e: apply enterprise edition patchs"
echo "-h: prints this help"
}
clean() {
rm -rf ./dist ./node_modules
}
dependencies() {
npm i
}
install() {
dependencies
npm run build
}
install_enterprise() {
dependencies
npm run build-enterprise
}
#-------------------------------------------------------------------------------
PARAMETERS="dche"
if [ $(getopt --version | tr -d " ") = "--" ]; then
TEMP_OPT=`getopt $PARAMETERS "$@"`
else
TEMP_OPT=`getopt -o $PARAMETERS -n 'build.sh' -- "$@"`
fi
DEPENDENCIES="no"
CLEAN="no"
ENTERPRISE="no"
eval set -- "$TEMP_OPT"
while true ; do
case "$1" in
-d) DEPENDENCIES="yes" ; shift ;;
-c) CLEAN="yes" ; shift ;;
-e) ENTERPRISE="yes" ; shift;;
-h) usage; exit 0;;
--) shift ; break ;;
*) usage; exit 1 ;;
esac
done
if [ "$CLEAN" = "yes" ]; then
clean
exit 0
fi
if [ "$DEPENDENCIES" = "yes" ]; then
dependencies
exit 0
fi
if [ "$ENTERPRISE" = "yes" ]; then
install_enterprise
exit 0
fi
install