ENTAXY-480 release version 1.8.3
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
entaxy:update-get = {
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
source scripts/update/update-get $args
|
||||
}
|
||||
entaxy:update-prepare = {
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
source scripts/update/update-prepare $args
|
||||
}
|
||||
entaxy:update-info = {
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
source scripts/update/update-info $args
|
||||
}
|
||||
entaxy:update-list = {
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
source scripts/update/update-list $args
|
||||
}
|
||||
entaxy:update-install = {
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
|
||||
__ORIGIN_ARGS__ = "${args}"
|
||||
source scripts/update/update-install $args
|
||||
}
|
||||
|
||||
__get_loaded_updates = {
|
||||
list = []
|
||||
fsref = ($.context getServiceReference org.apache.karaf.features.FeaturesService)
|
||||
fs = ($.context getService $fsref)
|
||||
|
||||
_features = ($fs getFeatures "entaxy-update-configuration")
|
||||
each $_features {
|
||||
$list add ($it getVersion)
|
||||
}
|
||||
|
||||
$.context ungetService $fsref
|
||||
$list
|
||||
}
|
||||
|
||||
complete -c entaxy:update-prepare -e
|
||||
complete -c entaxy:update-prepare -d "Prepare update for installation"
|
||||
complete -c entaxy:update-prepare -a '__get_loaded_updates'
|
@@ -0,0 +1,41 @@
|
||||
<!-- -->
|
||||
<configfile finalname="etc/scripts/entaxy.update.shell.script" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/etc~scripts~entaxy.update.shell
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/executor" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~executor
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/operations" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~operations
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/print-update-info" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~print-update-info
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/update-get" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~update-get
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/update-info" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~update-info
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/update-install" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~update-install
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/update-list" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~update-list
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/update-prepare" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~update-prepare
|
||||
</configfile>
|
||||
<!-- --><!-- -->
|
||||
<configfile finalname="scripts/update/utils" override="true">
|
||||
mvn:ru.entaxy.esb.update-management/update-management-components/1.8.3/script/scripts~update~utils
|
||||
</configfile>
|
||||
<!-- -->
|
@@ -0,0 +1,96 @@
|
||||
# source scripts/updtae/utils
|
||||
# source scripts/updtae/operations
|
||||
|
||||
__EXEC_PLAN = {
|
||||
|
||||
_thePlan = $1
|
||||
|
||||
each $_thePlan {
|
||||
|
||||
_data = $it
|
||||
|
||||
# echo "DATA :: ${_data}"
|
||||
|
||||
_rebootVal = ($_data get "reboot")
|
||||
_reboot = ($_rebootVal equals "true")
|
||||
_forceReboot = ($_rebootVal equals "force")
|
||||
|
||||
_sleep = ($_data get "sleep")
|
||||
|
||||
_operation = $_data get "operation"
|
||||
|
||||
__RESULT__ = [error=false]
|
||||
|
||||
_checkReboot = (__FALSE__)
|
||||
|
||||
echo
|
||||
echo "\-\-\-"
|
||||
echo " Perfoming operation: ${_operation}"
|
||||
|
||||
_result = __exec_operation ${_operation} ${_data}
|
||||
|
||||
|
||||
if { $_operation equals "feature" } {
|
||||
|
||||
_st = $__RESULT__ get "status"
|
||||
echo "\>\> ...${_st}"
|
||||
|
||||
if { NOT { $_result } } {
|
||||
echo "\>\> Failed upgrading \[${_featureName}\] from repo \[${_repo}\]"
|
||||
$__RESULT__ put "error" true
|
||||
$__RESULT__ put "status" "FAILED"
|
||||
break
|
||||
}
|
||||
|
||||
if { $_st equals "ALREADY_INSTALLED" } {
|
||||
echo "\>\> No changes made for \[${_featureName}\] from repo \[${_repo}\]"
|
||||
continue
|
||||
}
|
||||
|
||||
if { $_st equals "INSTALLED" } {
|
||||
echo "\>\> Successfully installed ${_featureName} from repo ${_repo}"
|
||||
_checkReboot = (__TRUE__)
|
||||
}
|
||||
}
|
||||
|
||||
# end of operation
|
||||
echo
|
||||
|
||||
# ensure we have status after last operation
|
||||
sz = $installPlan size
|
||||
_lastData = $installPlan get %(sz-1)
|
||||
if { $_lastData equals $_data } {
|
||||
_st = $__RESULT__ get "status"
|
||||
if { "${_st}" equals "" } {
|
||||
$__RESULT__ put "status" "INSTALLED"
|
||||
}
|
||||
}
|
||||
|
||||
# sleep - needed for refreshed initializers to complete
|
||||
if { NOT { $_sleep equals "" } } {
|
||||
echo "Sleeping for ${_sleep} seconds"
|
||||
shell:sleep $_sleep
|
||||
}
|
||||
|
||||
# process reboot
|
||||
if { $_checkReboot } {
|
||||
if { $_reboot } {
|
||||
echo "~~~~~~~~"
|
||||
echo "System must be rebooted"
|
||||
$__RESULT__ put "reboot" "true"
|
||||
$__RESULT__ put "status" "INSTALLING"
|
||||
break
|
||||
}
|
||||
if { $_forceReboot } {
|
||||
echo "~~~~~~~~"
|
||||
echo "System must be rebooted"
|
||||
$__RESULT__ put "reboot" "force"
|
||||
$__RESULT__ put "status" "INSTALLING"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,190 @@
|
||||
|
||||
source scripts/update/utils
|
||||
|
||||
# Installs (if not present) feature repo and upgrades (if not present) feature
|
||||
# $1 - map of params
|
||||
# return true if succeded
|
||||
__check_upgrade_feature = {
|
||||
|
||||
featuresService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
|
||||
_params = $1
|
||||
|
||||
# echo " :: __check_upgrade_feature :: "
|
||||
|
||||
_repoToInstall = ($_params get "repo")
|
||||
_featureName = ($_params get "feature")
|
||||
_upgrade = ($_params get "upgrade")
|
||||
|
||||
_u = ""
|
||||
|
||||
if { $_upgrade } {
|
||||
_u = "-u"
|
||||
}
|
||||
|
||||
_res = (__TRUE__)
|
||||
|
||||
echo "... process repo: ${_repoToInstall} ..."
|
||||
|
||||
_repoResult = __utils_check_install_repo $_repoToInstall
|
||||
if { NOT { $_repoResult } } {
|
||||
__RESULT__ = [error=true message="Failed installing repository: ${_repoToInstall}" status="FAILED"]
|
||||
_res = (__FALSE__)
|
||||
} else {
|
||||
echo "... process feature: ${_featureName} ..."
|
||||
|
||||
_feature = ($featuresService getFeature $_featureName $_version)
|
||||
if { $_feature equals '' } {
|
||||
__RESULT__ = [error=true message="Feature not found: ${_featureName}" status="FAILED"]
|
||||
_res = (__FALSE__)
|
||||
} else {
|
||||
_featureId = $_feature getId
|
||||
_state = ($featuresService getState $_featureId) toString
|
||||
|
||||
if { NOT { $_state equals "Started" } } {
|
||||
echo "\>\> Installing feature ${_featureName}/${_version} ..."
|
||||
try {
|
||||
feature:install -v "${_u}" "${_featureName}/${_version}"
|
||||
__RESULT__ = [error=false status="INSTALLED"]
|
||||
} catch {
|
||||
__RESULT__ = [error=true message="Error installing feature: ${_featureName}" status="FAILED"]
|
||||
echo "\>\> ... failed"
|
||||
_res = (__FALSE__)
|
||||
}
|
||||
if { $_res } {
|
||||
echo "\>\> ... installed"
|
||||
|
||||
_state = ($featuresService getState $_featureId) toString
|
||||
|
||||
if { NOT { $_state equals "Started" } } {
|
||||
__RESULT__ = [error=true message="Error installing feature: ${_featureName}" status="FAILED"]
|
||||
_res = (__FALSE__)
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
__RESULT__ = [error=false status="ALREADY_INSTALLED"]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_s = $__RESULT__ get "status"
|
||||
# echo "Return status: ${_s}"
|
||||
|
||||
$_res
|
||||
}
|
||||
|
||||
__feature_post = {
|
||||
_res = $1
|
||||
_st = $__RESULT__ get "status"
|
||||
echo "\>\> ...${_st}"
|
||||
_toReturn = []
|
||||
|
||||
if { NOT { $_res } } {
|
||||
echo "\>\> Failed upgrading \[${_featureName}\] from repo \[${_repo}\]"
|
||||
$__RESULT__ put "error" true
|
||||
$__RESULT__ put "status" "FAILED"
|
||||
_toReturn = [break=(__TRUE__) checkReboot = (__FALSE__)]
|
||||
}
|
||||
|
||||
if { $_st equals "ALREADY_INSTALLED" } {
|
||||
echo "\>\> No changes made for \[${_featureName}\] from repo \[${_repo}\]"
|
||||
_toReturn = [continue=(__TRUE__) checkReboot = (__FALSE__)]
|
||||
}
|
||||
|
||||
if { $_st equals "INSTALLED" } {
|
||||
echo "\>\> Successfully installed ${_featureName} from repo ${_repo}"
|
||||
_toReturn = [checkReboot = (__TRUE__)]
|
||||
}
|
||||
|
||||
# echo "_toReturn :: "
|
||||
# echo ${_toReturn}
|
||||
|
||||
$_toReturn
|
||||
}
|
||||
|
||||
commonsIoId = [ ((list -s -t 0 | grep "org.apache.commons.io") split ' ') ] get 0
|
||||
# echo "!!!! COMMONS-IO :: ${commonsIoId}"
|
||||
|
||||
__backup = {
|
||||
_params = $1
|
||||
|
||||
_action = ($_params get "action")
|
||||
_origin = ($_params get "source")
|
||||
_bak = "${_origin}.bak"
|
||||
|
||||
echo "\>\> EXEC BACKUP \[$_action\]"
|
||||
|
||||
if { $_action equals "create" } {
|
||||
_overwrite = ($_params get "overwrite")
|
||||
_from = new (($.context bundle) loadClass java.io.File) $_origin
|
||||
_to = new (($.context bundle) loadClass java.io.File) "$_bak"
|
||||
if { $_overwrite } {
|
||||
_exists = ($_to exists)
|
||||
if { NOT { $_exists } } {
|
||||
_r = ((($.context bundle %(commonsIoId+0)) loadClass org.apache.commons.io.FileUtils) copyFile $_from $_to)
|
||||
} else {
|
||||
echo "\>\> .. skipping: backup already exists"
|
||||
}
|
||||
} else {
|
||||
_r = ((($.context bundle %(commonsIoId+0)) loadClass org.apache.commons.io.FileUtils) copyFile $_from $_to)
|
||||
}
|
||||
}
|
||||
if { $_action equals "restore" } {
|
||||
_to = new (($.context bundle) loadClass java.io.File) $_origin
|
||||
_from = new (($.context bundle) loadClass java.io.File) "$_bak"
|
||||
_r = ((($.context bundle %(commonsIoId+0)) loadClass org.apache.commons.io.FileUtils) copyFile $_from $_to)
|
||||
}
|
||||
if { $_action equals "clean" } {
|
||||
_from = new (($.context bundle) loadClass java.io.File) "$_bak"
|
||||
_exists = ($_from exists)
|
||||
if { $_exists } {
|
||||
_r = ((($.context bundle %(commonsIoId+0)) loadClass org.apache.commons.io.FileUtils) forceDelete $_from)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__OPERATIONS = new java.util.HashMap
|
||||
|
||||
__add_operation = {
|
||||
$__OPERATIONS put $1 $2
|
||||
}
|
||||
|
||||
__exec_operation = {
|
||||
_oper = $1
|
||||
_data = $2
|
||||
# echo "__exec_operation ${_oper} ${_data}"
|
||||
# echo ($__OPERATIONS get $_oper)
|
||||
if { $__OPERATIONS containsKey $_oper } {
|
||||
_toExec = $__OPERATIONS get $_oper
|
||||
# echo $_toExec
|
||||
_execString = "${_toExec} \${_data}"
|
||||
# echo $_execString
|
||||
eval $_execString
|
||||
} else {
|
||||
"OPERATION_NOT_FOUND"
|
||||
}
|
||||
}
|
||||
|
||||
__exec_operation_post = {
|
||||
_oper = $1
|
||||
_mainResult = $2
|
||||
echo "__exec_operation ${_oper}-post ${_mainResult}"
|
||||
echo ($__OPERATIONS get "${_oper}-post")
|
||||
if { $__OPERATIONS containsKey "${_oper}-post" } {
|
||||
_toExec = $__OPERATIONS get "${_oper}-post"
|
||||
echo $_toExec
|
||||
_execString = "${_toExec} \${_mainResult}"
|
||||
echo $_execString
|
||||
eval $_execString
|
||||
} else {
|
||||
"NOT_FOUND"
|
||||
}
|
||||
}
|
||||
|
||||
__add_operation "feature" __check_upgrade_feature
|
||||
__add_operation "feature-post" __feature_post
|
||||
__add_operation "backup" __backup
|
@@ -0,0 +1,84 @@
|
||||
_version = $1
|
||||
_versionFormatted = ($_version replaceAll '-' '.')
|
||||
|
||||
if { NOT { "noHeader" equals $2 } } {
|
||||
|
||||
# print header
|
||||
# ID:20 Version:20 Type:12 Status:20 Repository:
|
||||
echo " ID \| Version \| Type \| Status \| Repository "
|
||||
echo " -------------------------------------------------------------------------------------------------- "
|
||||
|
||||
}
|
||||
|
||||
|
||||
__printLine = {
|
||||
|
||||
# $1 - list of data
|
||||
# $2 - list of lengths
|
||||
# $3 - list of prefixes
|
||||
|
||||
_result = ""
|
||||
i = 0
|
||||
_lengths = $2
|
||||
_prefixes = $3
|
||||
|
||||
# echo "__printLine"
|
||||
# echo (${i} getClass)
|
||||
|
||||
t = ($_lengths get ${i})
|
||||
# echo $t
|
||||
|
||||
each $1 {
|
||||
_length = ($_lengths get ${i})
|
||||
_prefix = ($_prefixes get $i)
|
||||
_value = ((($.context bundle) loadClass java.lang.String) format "\%-${_length}s" "${_prefix}${it}" )
|
||||
|
||||
# echo $_value
|
||||
|
||||
if { NOT { $_result equals ''} } {
|
||||
_result = "${_result}\|"
|
||||
}
|
||||
_result = "${_result}${_value}"
|
||||
# echo (${i} getClass)
|
||||
%(i+=1)
|
||||
# echo (${i} getClass)
|
||||
}
|
||||
|
||||
# _id = ((($.context bundle) loadClass java.lang.String) format "\%-20s" $2 )
|
||||
# _version = ((($.context bundle) loadClass java.lang.String) format "\%-20s" $3 )
|
||||
# _status = ((($.context bundle) loadClass java.lang.String) format "\%-16s" $4 )
|
||||
# _repo = ((($.context bundle) loadClass java.lang.String) format "\%-20s" $5 )
|
||||
|
||||
# echo "${_id}\|${_version}\|${_status}\|${_repo}"
|
||||
echo $_result
|
||||
}
|
||||
|
||||
_pid = "entaxy.update.$_versionFormatted"
|
||||
_configExists = config:exists $_pid
|
||||
|
||||
if { $_configExists } {
|
||||
|
||||
featuresService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
configService = (service:get org.osgi.service.cm.ConfigurationAdmin)
|
||||
configuration = ($configService getConfiguration $_pid)
|
||||
properties = ($configuration getProperties)
|
||||
|
||||
_configFeature = ($featuresService getFeature "entaxy-update-configuration" $_version)
|
||||
|
||||
_values = [($properties get 'update.id') ($properties get "update.version") ($properties get "update.type") ($properties get "update.status") ($properties get "update.repo")]
|
||||
_lengths = [20 20 12 20 10]
|
||||
_prefixes = [' ' ' ' ' ' ' ' ' ']
|
||||
|
||||
__printLine $_values $_lengths $_prefixes
|
||||
|
||||
_components = ( config:property-get -p $_pid "components") toString
|
||||
_componentsList = $_components split ","
|
||||
|
||||
_prefixes = [' - ' ' * ' ' ' ' ' ' ']
|
||||
|
||||
each $_componentsList {
|
||||
_component = (${it}) trim
|
||||
_values = [($properties get "${_component}.feature") ($properties get "${_component}.current.version") "" ($properties get "${_component}.status") ($properties get "${_component}.update.repo")]
|
||||
__printLine $_values $_lengths $_prefixes
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
_version = $1
|
||||
|
||||
echo
|
||||
echo "************"
|
||||
echo Getting update with version $_version
|
||||
echo "************"
|
||||
echo
|
||||
|
||||
_repo = (feature:repo-list | grep ru.entaxy.esb/update/$_version)
|
||||
_repo_length = ($_repo length)
|
||||
if { $_repo_length'' equals "0" } {
|
||||
echo "\>\> Installing Entaxy update $_version repository..."
|
||||
feature:repo-add mvn:ru.entaxy.esb/update/$_version/xml/update
|
||||
echo "\>\> ... installed"
|
||||
} else {
|
||||
echo "\>\> Entaxy update $_version repository is already installed"
|
||||
}
|
||||
|
||||
_versionFormatted = ($_version toString) replaceAll "-" "."
|
||||
|
||||
service = (service:get org.apache.karaf.features.FeaturesService)
|
||||
|
||||
_configFeature = ($service getFeature "entaxy-update-configuration" $_version)
|
||||
_configFeatureId = $_configFeature getId
|
||||
_state = ($service getState $_configFeatureId) toString
|
||||
|
||||
echo
|
||||
if { NOT { $_state equals "Started" } } {
|
||||
echo "\>\> Installing Entaxy update $_version configuration..."
|
||||
feature:install -v -r "entaxy-update-configuration"/$_version
|
||||
echo "\>\> ... installed"
|
||||
}
|
||||
|
||||
_state = ($service getState $_configFeatureId) toString
|
||||
|
||||
echo
|
||||
if { $_state equals "Started" } {
|
||||
echo "Configuration loaded for version $_version"
|
||||
} else {
|
||||
echo "Configuration load failed for version $_version"
|
||||
}
|
||||
echo
|
@@ -0,0 +1,14 @@
|
||||
_version = $1
|
||||
_versionFormatted = ($_version replaceAll '-' '.')
|
||||
|
||||
featureService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
|
||||
_configFeature = ($featureService getFeature "entaxy-update-configuration" $_version)
|
||||
|
||||
if { $_configFeature equals ''} {
|
||||
echo "!!!"
|
||||
echo "Update ${_version} not found"
|
||||
} else {
|
||||
source scripts/update/print-update-info $_version
|
||||
}
|
||||
echo
|
@@ -0,0 +1,271 @@
|
||||
source scripts/update/utils
|
||||
|
||||
_version = $1
|
||||
_versionFormatted = ($_version replaceAll '-' '.')
|
||||
|
||||
partial = (__FALSE__)
|
||||
|
||||
argsSplitted = $__ORIGIN_ARGS__ split " "
|
||||
|
||||
each $argsSplitted {
|
||||
|
||||
_arg = $it
|
||||
_val = $_arg trim
|
||||
|
||||
if { "partial" equals $_val } {
|
||||
partial = (__TRUE__)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
featureService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
|
||||
_configFeature = ($featureService getFeature "entaxy-update-configuration" $_version)
|
||||
|
||||
__set_component_status = {
|
||||
_comp = $1
|
||||
_prop = "${_comp}.status"
|
||||
if { $_comp equals '' } {
|
||||
_prop = "update.status"
|
||||
}
|
||||
config:edit $_pid
|
||||
config:property-set "${_prop}" $2
|
||||
config:update
|
||||
}
|
||||
|
||||
if { $_configFeature equals ''} {
|
||||
echo "!!!"
|
||||
echo "Update ${_version} not found"
|
||||
} else {
|
||||
|
||||
_pid = "entaxy.update.$_versionFormatted"
|
||||
|
||||
configService = (service:get org.osgi.service.cm.ConfigurationAdmin)
|
||||
configuration = ($configService getConfiguration $_pid)
|
||||
properties = ($configuration getProperties)
|
||||
|
||||
_components = ( $properties get "components") toString
|
||||
_componentsList = $_components split ","
|
||||
|
||||
total = ($_componentsList length)
|
||||
installed = new java.util.ArrayList
|
||||
toInstall = new java.util.ArrayList
|
||||
blocked = new java.util.ArrayList
|
||||
|
||||
each $_componentsList {
|
||||
|
||||
_component = $it
|
||||
_status = ($properties get "${_component}.status")
|
||||
# echo "${it} : ${_status}"
|
||||
|
||||
if { $_status equals "INSTALLED" } {
|
||||
($installed add $_component)
|
||||
continue
|
||||
}
|
||||
|
||||
if { $_status equals "VERSION_MISMATCH" } {
|
||||
echo "!!! ERROR !!!"
|
||||
echo "Update can not be installed: VERSION_MISMATCH for component \[${_component}\]"
|
||||
break
|
||||
}
|
||||
|
||||
_repo = ($properties get "${_component}.update.repo")
|
||||
if { $_repo equals '' } {
|
||||
_status = "REPO_NOT_FOUND"
|
||||
|
||||
__set_component_status ${_component} $_status
|
||||
|
||||
} else {
|
||||
|
||||
# echo " CHECK !!!"
|
||||
_exists = __utils_check_install_repo $_repo
|
||||
|
||||
if { NOT { $_exists } } {
|
||||
_status = "REPO_NOT_FOUND"
|
||||
__set_component_status ${_component} $_status
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if { $_status equals "REPO_NOT_FOUND" } {
|
||||
|
||||
($blocked add $_component)
|
||||
|
||||
if { $partial } {
|
||||
|
||||
echo ""
|
||||
echo "\-\-\- INFO \-\-\-"
|
||||
echo "Update can not be installed: REPO_NOT_FOUND for component \[${_component}\]"
|
||||
echo "Partial update is allowed, so the process will move on"
|
||||
echo ""
|
||||
continue
|
||||
|
||||
} else {
|
||||
echo ""
|
||||
echo "!!! ERROR !!!"
|
||||
echo "Update can not be installed: REPO_NOT_FOUND for component \[${_component}\]"
|
||||
echo "Partial update is NOT allowed, so the process will stop"
|
||||
echo ""
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
($toInstall add $_component)
|
||||
|
||||
}
|
||||
|
||||
# echo $total
|
||||
# echo $installed
|
||||
# echo $toInstall
|
||||
# echo $blocked
|
||||
|
||||
_processInstall = (__FALSE__)
|
||||
|
||||
if { ($toInstall isEmpty) } {
|
||||
echo "Nothing to install"
|
||||
} else {
|
||||
sz = ($toInstall size)
|
||||
if { %(sz < total) } {
|
||||
# echo "Partial install"
|
||||
_processInstall = $partial
|
||||
} else {
|
||||
_processInstall = (__TRUE__)
|
||||
}
|
||||
}
|
||||
|
||||
_rebootNeeded = new (($.context bundle) loadClass java.lang.Boolean) 'false'
|
||||
|
||||
# echo
|
||||
# echo "${toInstall}"
|
||||
# echo ($toInstall size)
|
||||
# echo
|
||||
|
||||
totalToInstall = ($toInstall size)
|
||||
# echo "TOTAL :: ${totalToInstall}"
|
||||
|
||||
if { $_processInstall } {
|
||||
__set_component_status '' "INSTALLING"
|
||||
each $toInstall {
|
||||
_component = $it
|
||||
_baseFeatureName = $properties get "${_component}.feature"
|
||||
_featureName = "${_baseFeatureName}-update"
|
||||
_feature = ($featureService getFeature "${_featureName}" $_version)
|
||||
_featureStatus = ($featureService getState $_feature) toString
|
||||
if { $_featureStatus equals "Uninstalled" } {
|
||||
feature:install -v -r "${_featureName}/$_version"
|
||||
_featureStatus = ($featureService getState $_feature) toString
|
||||
# echo " AFTER INSTALL :: ${_featureStatus}"
|
||||
if { NOT { $_featureStatus equals "Started" } } {
|
||||
__set_component_status ${_component} "FEATURE_INSTALL_FAILED"
|
||||
($blocked add $_component)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
karafRoot = ((($.context bundle) loadClass java.lang.System) getProperty 'karaf.home')
|
||||
cd $karafRoot
|
||||
cd updates/$_version
|
||||
_files = (shell:ls -m) toString
|
||||
cd $karafRoot
|
||||
|
||||
_filesArr = ($_files split ",")
|
||||
_filesList = new java.util.ArrayList
|
||||
each $_filesArr {
|
||||
$_filesList add ($it trim)
|
||||
}
|
||||
_current = $properties get "${_component}.current.version"
|
||||
_componentFeatureName = $properties get "${_component}.feature"
|
||||
li = $_current length
|
||||
_script = ""
|
||||
while { %(li>0) } {
|
||||
|
||||
_current = $_current substring 0 $li
|
||||
_scriptName = "${_componentFeatureName}.${_current}.update"
|
||||
|
||||
# echo "TEST :: $_scriptName"
|
||||
if { $_filesList contains $_scriptName } {
|
||||
_script = $_scriptName
|
||||
break
|
||||
}
|
||||
|
||||
li = $_current lastIndexOf "."
|
||||
|
||||
|
||||
}
|
||||
if { $_script equals '' } {
|
||||
|
||||
_scriptName = "${_componentFeatureName}.update"
|
||||
echo "TEST :: $_scriptName"
|
||||
}
|
||||
|
||||
# echo "SCRIPT :: ${_scriptName}"
|
||||
|
||||
echo "\>\> Running installations script"
|
||||
echo "\>\> updates/${_version}/${_script}"
|
||||
|
||||
source updates/$_version/$_script
|
||||
|
||||
# echo "RESULT :: ${__RESULT__}"
|
||||
_error = ($__RESULT__ get "error")
|
||||
|
||||
if { $_error } {
|
||||
_message = $__RESULT__ get "message"
|
||||
echo ""
|
||||
echo "!!! ERROR !!!"
|
||||
echo "${_message}"
|
||||
echo
|
||||
}
|
||||
|
||||
_resultStatus = $__RESULT__ get "status"
|
||||
if { $_resultStatus equals 'ALREADY_INSTALLED' } {
|
||||
_resultStatus = "INSTALLED"
|
||||
}
|
||||
|
||||
if { $_resultStatus equals 'INSTALLED' } {
|
||||
%(totalToInstall-=1)
|
||||
}
|
||||
|
||||
if { NOT { $_resultStatus equals '' } } {
|
||||
__set_component_status ${_component} $_resultStatus
|
||||
}
|
||||
|
||||
_reboot = ($__RESULT__ get "reboot")
|
||||
if { NOT { $_reboot equals "" } } {
|
||||
if { NOT { $_reboot equals "false" } } {
|
||||
_rebootNeeded = (__TRUE__)
|
||||
echo "** the system will reboot now to apply updates"
|
||||
echo
|
||||
echo "** PLEASE RUN THE SCRIPT AGAIN AFTER RESTART **"
|
||||
if { $_reboot equals "force" } {
|
||||
shutdown -r -f
|
||||
} else {
|
||||
shutdown -r
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
blockedSize = ($blocked size)
|
||||
|
||||
if { NOT { $_rebootNeeded } } {
|
||||
|
||||
if { %(totalToInstall+blockedSize>0) } {
|
||||
__set_component_status '' "PARTIAL_INSTALLED"
|
||||
} else {
|
||||
__set_component_status '' "INSTALLED"
|
||||
}
|
||||
|
||||
echo
|
||||
echo "*********"
|
||||
echo "** UPDATE FINISHED"
|
||||
echo "*********"
|
||||
source scripts/update/print-update-info $_version
|
||||
echo
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
#_version = $1
|
||||
#_versionFormatted = ($_version replaceAll '-' '.')
|
||||
|
||||
echo
|
||||
|
||||
#print header only
|
||||
source scripts/update/print-update-info "0"
|
||||
|
||||
featuresService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
_features = ( $featuresService getFeatures "entaxy-update-configuration" )
|
||||
|
||||
each ($_features) {
|
||||
|
||||
version = ($it getVersion)
|
||||
source scripts/update/print-update-info $version "noHeader"
|
||||
|
||||
}
|
||||
echo
|
@@ -0,0 +1,136 @@
|
||||
_version = $1
|
||||
|
||||
echo
|
||||
echo "************"
|
||||
echo Preparing update with version $_version
|
||||
echo "************"
|
||||
echo
|
||||
|
||||
_versionFormatted = ($_version toString) replaceAll "-" "."
|
||||
|
||||
_pid = "entaxy.update.$_versionFormatted"
|
||||
_configExists = config:exists $_pid
|
||||
|
||||
featuresService = (service:get org.apache.karaf.features.FeaturesService)
|
||||
configService = (service:get org.osgi.service.cm.ConfigurationAdmin)
|
||||
configuration = ($configService getConfiguration $_pid)
|
||||
properties = ($configuration getProperties)
|
||||
|
||||
_found = (new java.util.HashMap)
|
||||
|
||||
if { $_configExists } {
|
||||
_components = ( config:property-get -p $_pid "components") toString
|
||||
_componentsList = $_components split ","
|
||||
|
||||
totalCount = 0
|
||||
installedCount = 0
|
||||
|
||||
each $_componentsList {
|
||||
_component = (${it}) trim
|
||||
_componentFeatureNameProp = "${_component}\.feature"
|
||||
# echo "${_componentFeatureNameProp}"
|
||||
_componentFeatureName = ( config:property-get -p $_pid ${_componentFeatureNameProp} )
|
||||
# echo $_componentFeatureName
|
||||
_features = ($featuresService getFeatures $_componentFeatureName )
|
||||
|
||||
each ($_features) {
|
||||
_v = ($it getVersion)
|
||||
_status = ($featuresService getState $it) toString
|
||||
# echo $_v
|
||||
# echo ($it getId ) : ($it getName ) $_sqbr$_v']' '-' $_status
|
||||
if { $_status equals "Started" } {
|
||||
$_found put $_component $it
|
||||
|
||||
_versionsProp = "${_component}\.versions"
|
||||
# echo ":${_versionsProp}:${_pid}"
|
||||
_allowedVersionsValues = ( ( config:property-get -p $_pid ${_versionsProp}) toString )
|
||||
# echo $_allowedVersionsValues
|
||||
_allowedVersionsValues = $_allowedVersionsValues split ","
|
||||
_allowedVersions = new ArrayList
|
||||
each $_allowedVersionsValues {
|
||||
$_allowedVersions add (($it trim) replaceAll "-" ".")
|
||||
}
|
||||
# echo "ALLOWED VERSIONS: ${_allowedVersions}"
|
||||
_allowed = $_allowedVersions contains $_v
|
||||
_installed = $_versionFormatted equals $_v
|
||||
# echo "ALLOWED:${_allowed}"
|
||||
|
||||
_updateRepo = ($properties get "${_component}.update.repo")
|
||||
|
||||
config:edit $_pid
|
||||
|
||||
|
||||
config:property-set "${_component}.current" ($it getId)
|
||||
config:property-set "${_component}.current.repo" ($it getRepositoryUrl)
|
||||
config:property-set "${_component}.current.version" $_v
|
||||
config:property-set "${_component}.current.allowed" $_allowed
|
||||
if { $_allowed } {
|
||||
config:property-set "${_component}.status" "PREPARED"
|
||||
} else {
|
||||
if { $_installed } {
|
||||
%(installedCount+=1)
|
||||
config:property-set "${_component}.status" "VERSION_MISMATCH"
|
||||
} else {
|
||||
config:property-set "${_component}.status" "INSTALLED"
|
||||
}
|
||||
}
|
||||
|
||||
if { ($_updateRepo equals '') } {
|
||||
# echo "SET REPO"
|
||||
_currentRepoSplitted = ((($.context bundle) loadClass java.util.Arrays) asList (($it getRepositoryUrl) split "/"))
|
||||
# echo $_currentRepoSplitted
|
||||
_group = (${_currentRepoSplitted} get 0)
|
||||
_artifact = (${_currentRepoSplitted} get 1)
|
||||
_updateRepo = "${_group}/${_artifact}/${_version}/xml\/update"
|
||||
# echo $_updateRepo
|
||||
config:property-set "${_component}.update.repo" $_updateRepo
|
||||
}
|
||||
|
||||
config:update
|
||||
%(totalCount+=1)
|
||||
|
||||
# echo "FOUND:"
|
||||
# echo ($it getId)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_configFeature = ($featuresService getFeature "entaxy-update-configuration" $_version)
|
||||
|
||||
config:edit $_pid
|
||||
|
||||
_updateId = ($properties get "update.id")
|
||||
if { $_updateId equals '' } {
|
||||
config:property-set "update.id" "entaxy-update"
|
||||
}
|
||||
|
||||
_updateVersion = ($properties get "update.version")
|
||||
if { $_updateVersion equals '' } {
|
||||
config:property-set "update.version" $1
|
||||
}
|
||||
|
||||
_updateType = ($properties get "update.type")
|
||||
if { $_updateType equals '' } {
|
||||
config:property-set "update.type" "VERSION"
|
||||
}
|
||||
|
||||
if { $installedCount = 0 } {
|
||||
config:property-set "update.status" "PREPARED"
|
||||
} else {
|
||||
if { $installedCount = $totalCount } {
|
||||
config:property-set "update.status" "INSTALLED"
|
||||
} else {
|
||||
config:property-set "update.status" "PARTIAL"
|
||||
}
|
||||
}
|
||||
config:property-set "update.repo" ($_configFeature getRepositoryUrl)
|
||||
|
||||
config:update
|
||||
|
||||
source scripts/update/update-info $_version
|
||||
} else {
|
||||
echo "!!!"
|
||||
echo "Update configuration for version $_version NOT found"
|
||||
echo "Please run \'entaxy:get-update "${_version}"\'"
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
# $1 - feature repo url
|
||||
# return true if exists
|
||||
__utils_repo_exists = {
|
||||
_repo = $1
|
||||
|
||||
_repos = (feature:repo-list | grep $_repo)
|
||||
_repo_length = ($_repos length)
|
||||
_r = ( NOT { "$_repo_length" equals '0'} )
|
||||
# echo " ${_repo_length} :: $_r"
|
||||
$_r
|
||||
}
|
||||
|
||||
# $1 - feature repo url
|
||||
# return true if succeeded
|
||||
__utils_check_install_repo = {
|
||||
|
||||
_repo = $1
|
||||
|
||||
_exists = __utils_repo_exists $_repo
|
||||
|
||||
if { NOT { $_exists } } {
|
||||
try {
|
||||
r = (feature:repo-add $_repo)
|
||||
} catch { }
|
||||
|
||||
_exists = __utils_repo_exists $_repo
|
||||
}
|
||||
|
||||
$_exists
|
||||
}
|
||||
|
||||
__TRUE__ = {
|
||||
new (($.context bundle) loadClass java.lang.Boolean) 'true'
|
||||
}
|
||||
|
||||
__FALSE__ = {
|
||||
new (($.context bundle) loadClass java.lang.Boolean) 'false'
|
||||
}
|
Reference in New Issue
Block a user