openHAB install after windows service feature install
This commit is contained in:
70
LICENSE.TXT
Normal file
70
LICENSE.TXT
Normal file
@@ -0,0 +1,70 @@
|
||||
Eclipse Public License - v 1.0
|
||||
|
||||
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
||||
|
||||
1. DEFINITIONS
|
||||
|
||||
"Contribution" means:
|
||||
|
||||
a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
|
||||
b) in the case of each subsequent Contributor:
|
||||
i) changes to the Program, and
|
||||
ii) additions to the Program;
|
||||
where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
|
||||
"Contributor" means any person or entity that distributes the Program.
|
||||
|
||||
"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
|
||||
|
||||
"Program" means the Contributions distributed in accordance with this Agreement.
|
||||
|
||||
"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
|
||||
|
||||
2. GRANT OF RIGHTS
|
||||
|
||||
a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
|
||||
b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
|
||||
c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
|
||||
d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
|
||||
3. REQUIREMENTS
|
||||
|
||||
A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
|
||||
|
||||
a) it complies with the terms and conditions of this Agreement; and
|
||||
b) its license agreement:
|
||||
i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
|
||||
ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
|
||||
iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
|
||||
iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
|
||||
When the Program is made available in source code form:
|
||||
|
||||
a) it must be made available under this Agreement; and
|
||||
b) a copy of this Agreement must be included with each copy of the Program.
|
||||
Contributors may not remove or alter any copyright notices contained within the Program.
|
||||
|
||||
Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
|
||||
|
||||
4. COMMERCIAL DISTRIBUTION
|
||||
|
||||
Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
|
||||
|
||||
For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
|
||||
|
||||
5. NO WARRANTY
|
||||
|
||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
|
||||
|
||||
6. DISCLAIMER OF LIABILITY
|
||||
|
||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. GENERAL
|
||||
|
||||
If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
||||
|
||||
If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
|
||||
|
||||
All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
|
||||
|
||||
Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
|
||||
|
||||
This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
|
||||
1
addons/README
Normal file
1
addons/README
Normal file
@@ -0,0 +1 @@
|
||||
This folder can be used to deploy artifacts into the openHAB runtime.
|
||||
5
conf/html/index.html
Normal file
5
conf/html/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<h1>openHAB user provided static content</h1>
|
||||
<p>Serve your own static html pages or resources from here. Files stored in the openHAB configuration subfolder <tt>html</tt> will be available through the HTTP server of openHAB, e.g. <a href="http://device-address:8080/static/image.png">http://device-address:8080/static/image.png</a>.</p>
|
||||
<p>Resources for sitemap elements (image, video,...) can also be provided though this folder.</p>
|
||||
</html>
|
||||
3
conf/html/readme.txt
Normal file
3
conf/html/readme.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Serve your own static html pages or resources from here.
|
||||
Files stored in this folder will be available through the HTTP server of openHAB, e.g. "http://device-address:8080/static/image.png".
|
||||
Resources for sitemap elements (image, video,...) can also be provided though this folder.
|
||||
6
conf/icons/classic/readme.txt
Normal file
6
conf/icons/classic/readme.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Your additional icons go here.
|
||||
Icons can be provided as png (32x32) or preferably as svg files.
|
||||
ClassicUI and BasicUI can be configured to accept svg (default) or png icons.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/items.html#icons
|
||||
5
conf/items/readme.txt
Normal file
5
conf/items/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your item definitions go here.
|
||||
All items files have to have the ".items" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/items.html
|
||||
5
conf/persistence/readme.txt
Normal file
5
conf/persistence/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your persistence configuration goes here.
|
||||
All persistence files have to have the ".persist" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/persistence.html
|
||||
5
conf/rules/readme.txt
Normal file
5
conf/rules/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your rules go here.
|
||||
All rule files have to have the ".rules" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/rules-dsl.html
|
||||
5
conf/scripts/readme.txt
Normal file
5
conf/scripts/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your scripts go here.
|
||||
All script files have to have the ".script" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/rules-dsl.html#scripts
|
||||
50
conf/services/addons.cfg
Normal file
50
conf/services/addons.cfg
Normal file
@@ -0,0 +1,50 @@
|
||||
# The installation package of this openHAB instance
|
||||
# Note: This is only regarded at the VERY FIRST START of openHAB
|
||||
# Note: If you want to specify your add-ons yourself through entries below, set the package to "minimal"
|
||||
# as otherwise your definition might be in conflict with what the installation package defines.
|
||||
#
|
||||
# Optional. If not set, the dashboard (https://<yourserver>:8080/) will ask you to choose a package.
|
||||
#
|
||||
# Valid options:
|
||||
# - minimal : Installation only with dashboard, but no UIs or other add-ons. Use this for custom setups.
|
||||
# - simple : Setup for using openHAB purely through UIs - you need to expect MANY constraints in functionality!
|
||||
# - standard : Default setup for normal users, best for textual setup
|
||||
# - expert : Setup for expert users, especially for people migrating from openHAB 1.x
|
||||
# - demo : A demo setup which includes UIs, a few bindings, config files etc.
|
||||
#
|
||||
# See https://www.openhab.org/docs/configuration/packages.html for a detailed explanation of these packages.
|
||||
#
|
||||
#package = minimal
|
||||
|
||||
# Access Remote Add-on Repository
|
||||
# Defines whether the remote openHAB add-on repository should be used for browsing and installing add-ons.
|
||||
# This not only makes latest snapshots of add-ons available, it is also required for the installation of
|
||||
# any legacy 1.x add-on. (default is true)
|
||||
#
|
||||
#remote = true
|
||||
|
||||
# Include legacy 1.x bindings. If set to true, it also allows the installation of 1.x bindings for which there is
|
||||
# already a 2.x version available (requires remote repo access, see above). (default is false)
|
||||
#
|
||||
#legacy = true
|
||||
|
||||
# A comma-separated list of bindings to install (e.g. "binding = sonos,knx,zwave")
|
||||
#binding =
|
||||
|
||||
# A comma-separated list of UIs to install (e.g. "ui = basic,paper")
|
||||
#ui =
|
||||
|
||||
# A comma-separated list of persistence services to install (e.g. "persistence = rrd4j,jpa")
|
||||
#persistence =
|
||||
|
||||
# A comma-separated list of actions to install (e.g. "action = mail,pushover")
|
||||
#action =
|
||||
|
||||
# A comma-separated list of transformation services to install (e.g. "transformation = map,jsonpath")
|
||||
#transformation =
|
||||
|
||||
# A comma-separated list of voice services to install (e.g. "voice = marytts,freetts")
|
||||
#voice =
|
||||
|
||||
# A comma-separated list of miscellaneous services to install (e.g. "misc = myopenhab")
|
||||
#misc =
|
||||
6
conf/services/readme.txt
Normal file
6
conf/services/readme.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Your service configurations will reside here.
|
||||
All configuration files have to have the ".cfg" file extension.
|
||||
Service configuration files are automatically created as soon as you install an add-on that can be configured.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/services.html
|
||||
73
conf/services/runtime.cfg
Normal file
73
conf/services/runtime.cfg
Normal file
@@ -0,0 +1,73 @@
|
||||
##################### LOCALE ####################
|
||||
|
||||
# The default language that should be used. If not specified, the system default locale is used.
|
||||
# The ISO 639 alpha-2 or alpha-3 language code (if there is no alpha-2 one).
|
||||
# Example: "en" (English), "de" (German), "ja" (Japanese), "kok" (Konkani)
|
||||
#
|
||||
#org.eclipse.smarthome.core.localeprovider:language=
|
||||
|
||||
# The region that should be used.
|
||||
# ISO 3166 alpha-2 country code or UN M.49 numeric-3 area code.
|
||||
# Example: "US" (United States), "DE" (Germany), "FR" (France), "029" (Caribbean)
|
||||
#
|
||||
#org.eclipse.smarthome.core.localeprovider:region=
|
||||
|
||||
################ PERSISTENCE ####################
|
||||
|
||||
# The persistence service to use if no other is specified.
|
||||
#
|
||||
#org.eclipse.smarthome.persistence:default=
|
||||
|
||||
################### AUDIO #######################
|
||||
|
||||
# This parameter defines the default audio source to use (if not set, the first available one will be used.
|
||||
#
|
||||
#org.eclipse.smarthome.audio:defaultSource=
|
||||
|
||||
# This parameter defines the default audio sink to use (if not set, the first available one will be used.
|
||||
#
|
||||
#org.eclipse.smarthome.audio:defaultSink=
|
||||
|
||||
##################### VOICE ####################
|
||||
|
||||
# This parameter defines the default text-to-speech service to use (if not set, the first available one will be used.
|
||||
#
|
||||
#org.eclipse.smarthome.voice:defaultTTS=
|
||||
|
||||
# This parameter defines the default speech-to-text service to use (if not set, the first available one will be used.
|
||||
#
|
||||
#org.eclipse.smarthome.voice:defaultSTT=
|
||||
|
||||
# The default voice to use if no specific TTS service or voice is specified.
|
||||
#
|
||||
#org.eclipse.smarthome.voice:defaultVoice=
|
||||
|
||||
# The default human language interpreter to use if no other is specified.
|
||||
#
|
||||
#org.eclipse.smarthome.voice:defaultHLI=
|
||||
|
||||
################ MISCELLANOUS ####################
|
||||
|
||||
# The karaf sshHost parameter configures the bind address for the ssh login to karaf.
|
||||
# Default is 127.0.0.1 (localhost), so it is only possible to login from the local machine.
|
||||
#
|
||||
# Setting this to the address of another network interfaces will allow login from this network.
|
||||
# Setting this to 0.0.0.0 will allow login from all network interfaces.
|
||||
#
|
||||
# !!! Security warning !!!
|
||||
# Remember to change default login/password, if you allow external login.
|
||||
# See https://www.openhab.org/docs/administration/console.html for details.
|
||||
#
|
||||
#org.apache.karaf.shell:sshHost = 0.0.0.0
|
||||
|
||||
# Setting this to true will automatically approve all inbox entries and create Things for them,
|
||||
# so that they are immediately available in the system (default is false)
|
||||
#
|
||||
#org.eclipse.smarthome.inbox:autoApprove=true
|
||||
|
||||
# This setting allows to switch between a "simple" and an "advanced" mode for item management.
|
||||
# In simple mode (autoLinks=true), links and their according items are automatically created for new Things.
|
||||
# In advanced mode (autoLinks=false), the user has the full control about which items channels are linked to.
|
||||
# Existing links will remain untouched. (default is true)
|
||||
#
|
||||
#org.eclipse.smarthome.links:autoLinks=false
|
||||
5
conf/sitemaps/readme.txt
Normal file
5
conf/sitemaps/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your sitemap definitions go here.
|
||||
All sitemap files have to have the ".sitemap" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/sitemaps.html
|
||||
BIN
conf/sounds/barking.mp3
Normal file
BIN
conf/sounds/barking.mp3
Normal file
Binary file not shown.
BIN
conf/sounds/doorbell.mp3
Normal file
BIN
conf/sounds/doorbell.mp3
Normal file
Binary file not shown.
5
conf/things/readme.txt
Normal file
5
conf/things/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Your thing definitions go here.
|
||||
All thing files have to have the ".things" file extension and must follow a special syntax.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/things.html
|
||||
3
conf/transform/de.map
Normal file
3
conf/transform/de.map
Normal file
@@ -0,0 +1,3 @@
|
||||
CLOSED=zu
|
||||
OPEN=offen
|
||||
NULL=undefiniert
|
||||
4
conf/transform/en.map
Normal file
4
conf/transform/en.map
Normal file
@@ -0,0 +1,4 @@
|
||||
CLOSED=closed
|
||||
OPEN=open
|
||||
NULL=unknown
|
||||
|
||||
5
conf/transform/readme.txt
Normal file
5
conf/transform/readme.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Transformations like map or jsonpath can utilize configuration files with data definitions.
|
||||
These files have their specific file extensions and syntax definition.
|
||||
|
||||
Check out the openHAB documentation for more details:
|
||||
https://www.openhab.org/docs/configuration/transformations.html
|
||||
176
runtime/bin/backup
Normal file
176
runtime/bin/backup
Normal file
@@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
|
||||
getFullPath() {
|
||||
specDir="$(dirname "$1")"
|
||||
if cd "$specDir" 2>/dev/null; then
|
||||
OutputFile="$(pwd)/$(basename "$1")"
|
||||
else
|
||||
echo "Unable to locate specified directory '$specDir'"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
setup(){
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||
echo "Usage: backup [--full] [filename]"
|
||||
echo ""
|
||||
echo " e.g. ./backup << Makes a file with a timed filename"
|
||||
echo " ./backup myBackup.zip << Makes a file called myBackup.zip"
|
||||
echo " ./backup --full << Makes a full backup file with a timed filename"
|
||||
echo " ./backup --full myBackup.zip << Makes a full backup file called myBackup.zip"
|
||||
echo ""
|
||||
echo "Use this script to backup your openHAB configuration, you can use the 'restore' script"
|
||||
echo "from any machine to transfer your configuration across to another instance."
|
||||
echo ""
|
||||
echo "A full backup includes the tmp and cache directories that are normally excluded."
|
||||
echo ""
|
||||
echo "Set $OPENHAB_BACKUPS to change the default backup directory."
|
||||
echo "Set $OPENHAB_BACKUPS_TEMP to change the default backup temporary directory."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
## Ask to run as root to prevent us from running sudo in this script.
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run this script as root! (e.g. use sudo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v zip >/dev/null 2>&1 || {
|
||||
echo "'zip' program was not found, please install it first." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Set path variables
|
||||
if [ -r /etc/profile.d/openhab2.sh ]; then
|
||||
. /etc/profile.d/openhab2.sh
|
||||
elif [ -r /etc/default/openhab2 ]; then
|
||||
. /etc/default/openhab2
|
||||
fi
|
||||
|
||||
WorkingDir="$(cd "$(dirname "$0")" && cd ../.. && pwd -P)"
|
||||
|
||||
if [ -z "$OPENHAB_CONF" ]; then OPENHAB_CONF="$WorkingDir/conf"; fi
|
||||
if [ -z "$OPENHAB_USERDATA" ]; then OPENHAB_USERDATA="$WorkingDir/userdata"; fi
|
||||
if [ -z "$OPENHAB_BACKUPS" ]; then OPENHAB_BACKUPS="$WorkingDir/backups"; fi
|
||||
if [ -z "$OPENHAB_RUNTIME" ]; then OPENHAB_RUNTIME="$WorkingDir/runtime"; fi
|
||||
|
||||
echo "Using '$OPENHAB_CONF' as conf folder..."
|
||||
echo "Using '$OPENHAB_USERDATA' as userdata folder..."
|
||||
echo "Using '$OPENHAB_RUNTIME' as runtime folder..."
|
||||
|
||||
fileList="$OPENHAB_RUNTIME/bin/userdata_sysfiles.lst"
|
||||
|
||||
## Parse arguments
|
||||
if [ "$1" = "--full" ]; then
|
||||
echo "including cache"
|
||||
INCLUDE_CACHE="true"
|
||||
shift
|
||||
fi
|
||||
|
||||
timestamp=$(date +"%y_%m_%d-%H_%M_%S")
|
||||
## Set the filename
|
||||
if [ -z "$1" ]; then
|
||||
echo "Using '$OPENHAB_BACKUPS' as backup folder..."
|
||||
OutputFile="$OPENHAB_BACKUPS/openhab2-backup-$timestamp.zip"
|
||||
else
|
||||
getFullPath "$1"
|
||||
fi
|
||||
echo "Writing to '${OutputFile}'..."
|
||||
|
||||
## Check two of the standard openHAB folders to make sure we're backing up the right thing.
|
||||
if [ ! -d "$OPENHAB_USERDATA" ] || [ ! -d "$OPENHAB_CONF" ]; then
|
||||
echo "Configuration paths are invalid..." >&2
|
||||
echo "Try setting OPENHAB_USERDATA and OPENHAB_CONF environment variables." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Find the group and user of the current openHAB folders.
|
||||
OHUser=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $3}')
|
||||
OHGroup=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $4}')
|
||||
|
||||
CurrentVersion="$(awk '/openhab-distro/{print $3}' "$OPENHAB_USERDATA/etc/version.properties")"
|
||||
|
||||
## Store anything in temporary folders
|
||||
# Check if we should use TempDir from env $OPENHAB_BACKUPS_TEMP
|
||||
if [ -n "${OPENHAB_BACKUPS_TEMP}" ]; then
|
||||
TempDir="$OPENHAB_BACKUPS_TEMP";
|
||||
else
|
||||
TempDir="/tmp/openhab2/backup"
|
||||
fi
|
||||
echo "Making Temporary Directory if it is not already there"
|
||||
if [ ! -d "$TempDir" ]; then
|
||||
mkdir -p "$TempDir" || {
|
||||
echo "Failed to make temporary directory: $TempDir" >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
echo "Using $TempDir as TempDir"
|
||||
|
||||
## Clear older stuff if it exists
|
||||
rm -rf "${TempDir:?}/"*
|
||||
}
|
||||
|
||||
echo " "
|
||||
echo "#########################################"
|
||||
echo " openHAB 2.x.x backup script "
|
||||
echo "#########################################"
|
||||
echo " "
|
||||
|
||||
setup "$1" "$2"
|
||||
|
||||
## Set backup properties file.
|
||||
{
|
||||
echo "version=$CurrentVersion"
|
||||
echo "timestamp=$timestamp"
|
||||
echo "user=$OHUser"
|
||||
echo "group=$OHGroup"
|
||||
} > "$TempDir/backup.properties"
|
||||
|
||||
## Copy userdata and conf folders
|
||||
echo "Copying configuration to temporary folder..."
|
||||
mkdir -p "$TempDir/userdata"
|
||||
if [ -z "$INCLUDE_CACHE" ]; then
|
||||
find "${OPENHAB_USERDATA:?}/"* -prune -not -path '*/tmp' -and -not -path '*/cache' | xargs -I % cp -R % "$TempDir/userdata"
|
||||
else
|
||||
cp -a "${OPENHAB_USERDATA:?}/"* "$TempDir/userdata"
|
||||
fi
|
||||
mkdir -p "$TempDir/conf"
|
||||
cp -a "${OPENHAB_CONF:?}/"* "$TempDir/conf"
|
||||
|
||||
## Remove non-transferable userdata files
|
||||
echo "Removing unnecessary files..."
|
||||
if [ -f "$fileList" ]; then
|
||||
while IFS= read -r fileName
|
||||
do
|
||||
rm -rf "$TempDir/userdata/etc/$fileName"
|
||||
done < "$fileList"
|
||||
else
|
||||
echo "System Filelist not found, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## If the backup directory is inside userdata folder do not include it
|
||||
## Mainly for apt/rpm automatic
|
||||
if [ "$OPENHAB_BACKUPS" = "$OPENHAB_USERDATA/backups" ]; then
|
||||
echo "Backup Directory is inside userdata, not including in this backup!"
|
||||
rm -rf "$TempDir/userdata/backups"
|
||||
fi
|
||||
|
||||
## Create archive
|
||||
mkdir -p "$OPENHAB_BACKUPS"
|
||||
echo "Zipping folder..."
|
||||
|
||||
## Jump into directory before making zip
|
||||
## Cleans file structure
|
||||
( cd "$TempDir" || exit
|
||||
zip -qr "$OutputFile" . || {
|
||||
echo "zip failed to store a backup."
|
||||
exit 1
|
||||
}
|
||||
) || exit 1
|
||||
|
||||
echo "Removing temporary files..."
|
||||
rm -rf $TempDir
|
||||
|
||||
echo "Success! Backup made in $OutputFile"
|
||||
echo ""
|
||||
38
runtime/bin/backup.bat
Normal file
38
runtime/bin/backup.bat
Normal file
@@ -0,0 +1,38 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
|
||||
IF "%1"=="?" GOTO printArgs
|
||||
IF "%1"=="\?" GOTO printArgs
|
||||
IF "%1"=="/?" GOTO printArgs
|
||||
|
||||
SET bargs=
|
||||
|
||||
IF NOT [%1]==[] ( SET bargs=%bargs% -MaxFiles %~1% )
|
||||
IF NOT [%2]==[] ( SET bargs=%bargs% -OHDirectory %~2% )
|
||||
IF NOT [%3]==[] ( SET bargs=%bargs% -OHBackups %~3% )
|
||||
IF NOT [%4]==[] ( SET bargs=%bargs% -FileName %~4% )
|
||||
|
||||
CD %~dp0
|
||||
powershell -ExecutionPolicy Bypass -command "&{. .\backup.ps1; Backup-openHAB %bargs% }"
|
||||
SET LEVEL=%ERRORLEVEL%
|
||||
|
||||
if %LEVEL% LSS 0 (
|
||||
PAUSE
|
||||
EXIT /B %LEVEL%
|
||||
)
|
||||
EXIT /B 0
|
||||
|
||||
:printArgs
|
||||
ECHO Usage: backup.bat {MaxFiles} {OHDirectory} {OHBackups} {FileName}
|
||||
ECHO MaxFiles (optional) - The maximum number of backups to keep (specify 0 for no maximum)
|
||||
ECHO OHDirectory (optional) - The openHAB distribution directory
|
||||
ECHO OHBackups (optional) - The directory where backups are stored
|
||||
ECHO FileName (optional) - The backup file name (found in OHBackups)
|
||||
ECHO.
|
||||
ECHO Example to backup openHAB to the default locations
|
||||
ECHO backup.bat
|
||||
ECHO.
|
||||
ECHO Example to backup openHAB to "backup.zip" in "c:\openhab2\backups" keeping at most 10 backups:
|
||||
ECHO backup.bat 10 "c:\openhab2" "c:\openhab2\backups" "backup.zip"
|
||||
ECHO.
|
||||
EXIT /B -1
|
||||
209
runtime/bin/backup.ps1
Normal file
209
runtime/bin/backup.ps1
Normal file
@@ -0,0 +1,209 @@
|
||||
#Requires -Version 5.0
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
Function Backup-openHAB {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Backsup openHAB files.
|
||||
.DESCRIPTION
|
||||
The Backup-openHAB function performs the necessary tasks to backup openHAB.
|
||||
.PARAMETER OHDirectory
|
||||
The directory where openHAB is installed (default: current directory).
|
||||
.PARAMETER OHBackups
|
||||
The directory to backup the files to.
|
||||
.PARAMETER FileName
|
||||
The name of the zip file to create
|
||||
.PARAMETER MaxFiles
|
||||
The maximum number of files to keep
|
||||
.EXAMPLE
|
||||
Backup an openHAB instance to a zip file
|
||||
Backup-openHAB
|
||||
.EXAMPLE
|
||||
Backup the openHAB distribution in the C:\openHAB2 directory to c:\openHAB2-backup\backup.zip
|
||||
Backup-openHAB -OHDirectory C:\openHAB2 -OHBackups c:\openHAB2-backup -FileName backup.zip
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHDirectory = ".",
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHBackups,
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$FileName,
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[int]$MaxFiles
|
||||
)
|
||||
|
||||
begin {}
|
||||
process {
|
||||
|
||||
Import-Module $PSScriptRoot\common.psm1 -Force
|
||||
|
||||
Write-Host ""
|
||||
BoxMessage "openHAB 2.x.x backup script" Magenta
|
||||
Write-Host ""
|
||||
|
||||
# Check for admin (commented out - don't think we need it)
|
||||
# CheckForAdmin
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Checking the specified openHAB directory"
|
||||
$OHDirectory = GetOpenHABRoot $OHDirectory
|
||||
if ($OHDirectory -eq "") {
|
||||
exit PrintAndReturn "Could not find the userdata directory! Make sure you are in the openHAB directory or specify the -OHDirectory parameter!"
|
||||
}
|
||||
|
||||
$OHConf = GetOpenHABDirectory "OPENHAB_CONF" "$OHDirectory\conf"
|
||||
$OHUserData = GetOpenHABDirectory "OPENHAB_USERDATA" "$OHDirectory\userdata"
|
||||
$OHRuntime = GetOpenHABDirectory "OPENHAB_RUNTIME" "$OHDirectory\runtime"
|
||||
|
||||
if ([string]::IsNullOrEmpty($OHBackups)) {
|
||||
$OHBackups = GetOpenHABDirectory "OPENHAB_BACKUPS" "$OHDirectory\backups"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHConf -PathType Container)) {
|
||||
exit PrintAndReturn "Configuration directory does not exist: $OHConf"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHUserData -PathType Container)) {
|
||||
exit PrintAndReturn "Userdata directory does not exist: $OHUserData"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHRuntime -PathType Container)) {
|
||||
exit PrintAndReturn "Runtime directory does not exist: $OHRuntime"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHBackups -PathType Container)) {
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Creating backup directory $OHBackups"
|
||||
CreateDirectory $OHBackups
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Error creating backup directory $OHBackups - exiting" $_
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Yellow "Using $OHConf as conf folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHUserData as userdata folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHBackups as backups folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHRuntime as runtime folder"
|
||||
|
||||
$TempDir = "$(GetOpenHABTempDirectory)\backup"
|
||||
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Creating temporary backup directory $TempDir"
|
||||
CreateDirectory $TempDir
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Error creating temporary backup directory $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
try {
|
||||
$CurrentVersion = GetOpenHABVersion $OHUserData
|
||||
if ($CurrentVersion -eq "") {
|
||||
exit PrintAndReturn "Can't get the current openhab version from $OHDirectory - exiting"
|
||||
}
|
||||
|
||||
$timestamp = Get-Date -UFormat "%y_%m_%d-%H_%M_%S"
|
||||
$BackupProperites = "$TempDir\backup.properties"
|
||||
try {
|
||||
CreateFile $BackupProperites
|
||||
Write-Output "version=$CurrentVersion" -ErrorAction Stop | Add-Content $BackupProperites -ErrorAction Stop
|
||||
Write-Output "timestamp=$timestamp" -ErrorAction Stop | Add-Content $BackupProperites -ErrorAction Stop
|
||||
Write-Output "user=openhab" -ErrorAction Stop | Add-Content $BackupProperites -ErrorAction Stop
|
||||
Write-Output "group=openhab" -ErrorAction Stop | Add-Content $BackupProperites -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Can't create the temporary backup.properties file in $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Copying userdata and conf folder contents to temp directory"
|
||||
try {
|
||||
Copy-Item $OHUserData $TempDir -Recurse -ErrorAction Stop
|
||||
Copy-Item $OHConf $TempDir -Recurse -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Can't copy the userdata/conf directory to the temporary directory $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing unnecessary files"
|
||||
foreach ($sysFile in Get-Content "$OHRuntime\bin\userdata_sysfiles.lst") {
|
||||
DeleteIfExists "$TempDir\userdata\etc\$sysFile"
|
||||
}
|
||||
DeleteIfExists "$TempDir\userdata\cache" $True
|
||||
DeleteIfExists "$TempDir\userdata\tmp" $True
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Removing backup folder from backup userdata if it exists"
|
||||
DeleteIfExists "$TempDir\userdata\backups" $True
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Error removing unnecessary files from $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($FileName)) {
|
||||
$FileName = "$OHBackups\openhab2-backup-$timestamp.zip"
|
||||
} else {
|
||||
if (-NOT $FileName.EndsWith(".zip")) {
|
||||
$FileName = $FileName + ".zip";
|
||||
}
|
||||
|
||||
if ((Split-Path -Path $FileName) -eq "") {
|
||||
$FileName = "$OHBackups\$FileName"
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Path -Path $FileName) {
|
||||
Write-Host -ForegroundColor Yellow "Backup file $FileName already exists!"
|
||||
$confirmation = Read-Host "Do you wish to overwrite that file? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling backup"
|
||||
}
|
||||
DeleteIfExists $FileName
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Zipping up files to $FileName"
|
||||
try {
|
||||
Compress-Archive -Path "$TempDir\*" -DestinationPath $FileName -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Error zipping up files to $FileName - exiting" $_
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Backup created at $FileName"
|
||||
|
||||
if ($MaxFiles -gt 0) {
|
||||
Write-Host -ForegroundColor Cyan "Keeping only the last $MaxFiles backups"
|
||||
Get-ChildItem -Path $OHBackups -Filter *.zip | Sort LastWriteTime -Descending | Select -Skip $MaxFiles | %{
|
||||
Write-Host -ForegroundColor Cyan "Deleting $_"
|
||||
DeleteIfExists $_.FullName
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
# No printandthrows so we are catching an unknown error
|
||||
exit PrintAndReturn "Exception occurred backing up file" $_
|
||||
}
|
||||
finally {
|
||||
$parent = (Get-Item $TempDir).Parent.FullName
|
||||
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary directory $TempDir"
|
||||
DeleteIfExists $TempDir $True
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $TempDir - delete it manually"
|
||||
}
|
||||
|
||||
try {
|
||||
if (-Not (Test-Path "$parent\*")) {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary directory $parent"
|
||||
DeleteIfExists $parent $True
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $parent - delete it manually"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
139
runtime/bin/client
Normal file
139
runtime/bin/client
Normal file
@@ -0,0 +1,139 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
setupClassPath() {
|
||||
# Add the jars in the lib dir
|
||||
CLASSPATH="${KARAF_HOME}/system/org/apache/karaf/org.apache.karaf.client/4.2.1/org.apache.karaf.client-4.2.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/apache/sshd/sshd-core/1.7.0/sshd-core-1.7.0.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/fusesource/jansi/jansi/1.17.1/jansi-1.17.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/jline/jline/3.9.0/jline-3.9.0.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar"
|
||||
}
|
||||
|
||||
init() {
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Unlimit the number of file descriptors if possible
|
||||
unlimitFD
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
|
||||
# Locate the Karaf base directory
|
||||
locateBase
|
||||
|
||||
# Locate the Karaf data directory
|
||||
locateData
|
||||
|
||||
# Locate the Karaf etc directory
|
||||
locateEtc
|
||||
|
||||
# Setup the native library path
|
||||
setupNativePath
|
||||
|
||||
# Locate the Java VM to execute
|
||||
locateJava
|
||||
|
||||
# Determine the JVM vendor
|
||||
detectJVM
|
||||
|
||||
# Setup default options
|
||||
setupDefaults
|
||||
|
||||
# Setup classpath
|
||||
setupClassPath
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
exec "${JAVA}" ${JAVA_OPTS} \
|
||||
-Dkaraf.instances="${KARAF_HOME}/instances" \
|
||||
-Dkaraf.home="${KARAF_HOME}" \
|
||||
-Dkaraf.base="${KARAF_BASE}" \
|
||||
-Dkaraf.etc="${KARAF_ETC}" \
|
||||
-Djava.io.tmpdir="${KARAF_DATA}/tmp" \
|
||||
-Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
|
||||
${KARAF_OPTS} ${OPTS} \
|
||||
-classpath "${CLASSPATH}" \
|
||||
org.apache.karaf.client.Main "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
135
runtime/bin/client.bat
Normal file
135
runtime/bin/client.bat
Normal file
@@ -0,0 +1,135 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="client.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
|
||||
if "%JAVA_MIN_MEM%" == "" (
|
||||
set JAVA_MIN_MEM=128M
|
||||
)
|
||||
if "%JAVA_MAX_MEM%" == "" (
|
||||
set JAVA_MAX_MEM=512M
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
|
||||
rem Support for loading native libraries
|
||||
set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
|
||||
|
||||
rem Setup the Java Virtual Machine
|
||||
if not "%JAVA%" == "" goto :Check_JAVA_END
|
||||
set JAVA=java
|
||||
if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
|
||||
if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
|
||||
if not exist "%JAVA_HOME%" (
|
||||
call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
|
||||
goto END
|
||||
)
|
||||
:Check_JAVA_END
|
||||
|
||||
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
|
||||
|
||||
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
|
||||
set JAVA_OPTS=%JAVA_OPTS% %EXTRA_JAVA_OPTS%
|
||||
:KARAF_EXTRA_JAVA_OPTS_END
|
||||
|
||||
set CLASSPATH=%KARAF_HOME%\system\org\apache\karaf\org.apache.karaf.client\4.2.1\org.apache.karaf.client-4.2.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\apache\sshd\sshd-core\1.7.0\sshd-core-1.7.0.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\jline\jline\3.9.0\jline-3.9.0.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\fusesource\jansi\jansi\1.17.1\jansi-1.17.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\slf4j\slf4j-api\1.7.12\slf4j-api-1.7.12.jar
|
||||
|
||||
:EXECUTE
|
||||
if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8 %9
|
||||
if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
rem Execute the Java Virtual Machine
|
||||
"%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.instances="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.etc="%KARAF_ETC%" -Djava.io.tmpdir="%KARAF_DATA%\tmp" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %KARAF_OPTS% org.apache.karaf.client.Main %ARGS%
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
223
runtime/bin/common.psm1
Normal file
223
runtime/bin/common.psm1
Normal file
@@ -0,0 +1,223 @@
|
||||
#Requires -Version 5.0
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
function CheckForAdmin() {
|
||||
if (!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
throw "This script must be run as an Administrator. Start PowerShell with the Run as Administrator option"
|
||||
}
|
||||
}
|
||||
function GetOpenHABRoot() {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $dirName
|
||||
)
|
||||
|
||||
function IsOpenHabRoot() {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $dirName
|
||||
)
|
||||
return ((Test-Path "$dirName\userdata") -And (Test-Path -Path "$dirName\conf")) -Or (Test-Path -Path "$dirName\runtime");
|
||||
}
|
||||
|
||||
if ($dirName -eq ".") {
|
||||
$dirName = $PWD
|
||||
}
|
||||
|
||||
if (-Not (IsOpenHabRoot $dirName)) {
|
||||
$dirName = GetOpenHABDirectory "OPENHAB_HOME" ""
|
||||
if (-NOT $dirName -eq "") {
|
||||
return $dirName
|
||||
}
|
||||
|
||||
$dirName = $PSScriptRoot;
|
||||
while ($dirName -ne "" -and -not(IsOpenHabRoot $dirName)) {
|
||||
$dirName = Split-Path -Path $dirName -Parent
|
||||
}
|
||||
}
|
||||
|
||||
return $dirName
|
||||
}
|
||||
|
||||
function CreateDirectory() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $itemName
|
||||
)
|
||||
|
||||
New-Item -Path $itemName -ItemType directory -Force -Confirm:$False -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
function CreateFile() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $itemName
|
||||
)
|
||||
|
||||
New-Item -Path $itemName -ItemType file -Force -Confirm:$False -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
function DeleteIfExists() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $itemName,
|
||||
[Parameter(Mandatory = $False)]
|
||||
[boolean] $fallback
|
||||
|
||||
)
|
||||
|
||||
if (Test-Path $itemName -PathType Container) {
|
||||
try {
|
||||
Remove-Item $itemName -Force -Recurse -Confirm:$False -ErrorAction Stop | Out-Null
|
||||
} catch {
|
||||
# if fallback, try to remove all the files (recursively) instead of the directory
|
||||
if ($fallback -eq $True) {
|
||||
Get-ChildItem $itemName -File -Recurse -ErrorAction Stop | Remove-Item -Force -ErrorAction Stop
|
||||
} else {
|
||||
throw $_
|
||||
}
|
||||
}
|
||||
}
|
||||
ElseIf (Test-Path $itemName) {
|
||||
# note: -Recurse because sometimes check above doesn't catch a directory for some reason
|
||||
Remove-Item $itemName -Force -Recurse -Confirm:$False -ErrorAction Stop | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
function GetOpenHABVersion() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $OHUserData
|
||||
)
|
||||
|
||||
if (Test-Path "$OHUserData\etc\version.properties" -ErrorAction SilentlyContinue) {
|
||||
$VersionLine = Get-Content "$OHUserData\etc\version.properties" -ErrorAction SilentlyContinue | Where-Object { $_.Contains("openhab-distro")} -ErrorAction SilentlyContinue
|
||||
$CurrentVersionIndex = $VersionLine.IndexOf(":")
|
||||
if ($CurrentVersionIndex -gt -1) {
|
||||
return $VersionLine.Substring($currentVersionIndex + 2)
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function GetOpenHABTempDirectory() {
|
||||
return (GetOpenHABDirectory "TEMP" "c:\temp") + "\openhab"
|
||||
}
|
||||
|
||||
function GetOpenHABDirectory() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $environmentVariable,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[AllowEmptyString()]
|
||||
[string] $defaultValue
|
||||
|
||||
)
|
||||
# Check the user variables first, then the process variables then the machine variables
|
||||
$setting = "$([Environment]::GetEnvironmentVariable($environmentVariable, "User"))"
|
||||
if ($setting) {
|
||||
return $setting
|
||||
}
|
||||
|
||||
$setting = "$([Environment]::GetEnvironmentVariable($environmentVariable, "Process"))"
|
||||
if ($setting) {
|
||||
return $setting
|
||||
}
|
||||
|
||||
$setting = "$([Environment]::GetEnvironmentVariable($environmentVariable, "Machine"))"
|
||||
if ($setting) {
|
||||
return $setting
|
||||
}
|
||||
|
||||
return $defaultValue
|
||||
}
|
||||
|
||||
function CheckOpenHABRunning() {
|
||||
$m = (Get-WmiObject Win32_Process -Filter "name = 'java.exe'" |
|
||||
Where-Object { $_.CommandLine.Contains("openhab") } | Measure-Object)
|
||||
if ($m.Count -gt 0) {
|
||||
throw "openHAB seems to be running, stop it before running this update script"
|
||||
}
|
||||
|
||||
}
|
||||
function GetRelativePath() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $root,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $absPath
|
||||
)
|
||||
|
||||
$tmp = Get-Location -ErrorAction Stop
|
||||
Set-Location $root -ErrorAction Stop
|
||||
try {
|
||||
return Resolve-Path $absPath -Relative -ErrorAction Stop
|
||||
}
|
||||
finally {
|
||||
Set-Location $tmp -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
|
||||
function PrintAndReturn {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $msg,
|
||||
[Parameter(Mandatory = $False)]
|
||||
[System.Management.Automation.ErrorRecord] $ex,
|
||||
[Parameter(Mandatory = $False)]
|
||||
[int] $rc
|
||||
)
|
||||
BoxMessage $msg Red
|
||||
|
||||
if ($ex) {
|
||||
Write-Error $ex
|
||||
}
|
||||
|
||||
if ($rc) {
|
||||
return $rc
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
function PrintAndThrow {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $msg,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[System.Management.Automation.ErrorRecord] $ex
|
||||
)
|
||||
BoxMessage $msg Red
|
||||
Write-Error $ex
|
||||
|
||||
throw $ex.Exception
|
||||
}
|
||||
|
||||
function BoxMessage {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $msg,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[System.ConsoleColor] $color
|
||||
|
||||
)
|
||||
$pad = "#".PadRight($msg.Length + 6, "#")
|
||||
Write-Host -ForegroundColor $color $pad
|
||||
Write-Host -ForegroundColor $color "# $msg #"
|
||||
Write-Host -ForegroundColor $color $pad
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function "BoxMessage"
|
||||
Export-ModuleMember -Function "CheckForAdmin"
|
||||
Export-ModuleMember -Function "CheckOpenHABRunning"
|
||||
Export-ModuleMember -Function "CreateDirectory"
|
||||
Export-ModuleMember -Function "CreateFile"
|
||||
Export-ModuleMember -Function "DeleteIfExists"
|
||||
Export-ModuleMember -Function "GetOpenHABRoot"
|
||||
Export-ModuleMember -Function "GetOpenHABTempDirectory"
|
||||
Export-ModuleMember -Function "GetOpenHABDirectory"
|
||||
Export-ModuleMember -Function "GetOpenHABVersion"
|
||||
Export-ModuleMember -Function "GetRelativePath"
|
||||
Export-ModuleMember -Function "PrintAndReturn"
|
||||
Export-ModuleMember -Function "PrintAndThrow"
|
||||
33
runtime/bin/contrib/karaf-service-template.conf
Normal file
33
runtime/bin/contrib/karaf-service-template.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
|
||||
#
|
||||
# Karaf Service
|
||||
#
|
||||
KARAF_SERVICE_PATH="${KARAF_SERVICE_PATH}"
|
||||
KARAF_SERVICE_NAME="${KARAF_SERVICE_NAME}"
|
||||
KARAF_SERVICE_LOG="${KARAF_SERVICE_LOG}"
|
||||
KARAF_SERVICE_USER="${KARAF_SERVICE_USER}"
|
||||
KARAF_SERVICE_GROUP="${KARAF_SERVICE_GROUP}"
|
||||
KARAF_LOCKFILE="/var/lock/subsys/$KARAF_SERVICE_NAME"
|
||||
KARAF_SERVICE_PIDFILE="${KARAF_SERVICE_PIDFILE}"
|
||||
KARAF_SERVICE_EXECUTABLE="${KARAF_SERVICE_EXECUTABLE}"
|
||||
#
|
||||
# Karaf
|
||||
#
|
||||
|
||||
#
|
||||
# User
|
||||
#
|
||||
171
runtime/bin/contrib/karaf-service-template.init
Normal file
171
runtime/bin/contrib/karaf-service-template.init
Normal file
@@ -0,0 +1,171 @@
|
||||
#!/bin/sh
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
# Karaf control script
|
||||
# description: Karaf startup script
|
||||
# processname: ${KARAF_SERVICE_NAME}
|
||||
# pidfile: ${KARAF_SERVICE_PIDFILE}
|
||||
# config: ${KARAF_SERVICE_CONF}
|
||||
#
|
||||
|
||||
if [ -r "${KARAF_SERVICE_CONF}" ]; then
|
||||
. "${KARAF_SERVICE_CONF}"
|
||||
else
|
||||
echo "Error KARAF_SERVICE_CONF not defined"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Location of JDK
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
export JAVA_HOME
|
||||
fi
|
||||
|
||||
# Setup the JVM
|
||||
if [ -z "$JAVA" ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
else
|
||||
JAVA="java"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$STARTUP_WAIT" ]; then
|
||||
STARTUP_WAIT=30
|
||||
fi
|
||||
|
||||
if [ -z "$SHUTDOWN_WAIT" ]; then
|
||||
SHUTDOWN_WAIT=30
|
||||
fi
|
||||
|
||||
prog=${KARAF_SERVICE_NAME}
|
||||
|
||||
do_start() {
|
||||
echo "Starting $prog: "
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read ppid < "$KARAF_SERVICE_PIDFILE"
|
||||
if [ `ps -p $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
|
||||
echo "$prog is already running"
|
||||
return 1
|
||||
else
|
||||
rm -f "$KARAF_SERVICE_PIDFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
LOG_PATH=`dirname "$KARAF_SERVICE_LOG"`
|
||||
mkdir -p "$LOG_PATH"
|
||||
cat /dev/null > "$KARAF_SERVICE_LOG"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$KARAF_SERVICE_LOG"
|
||||
|
||||
PID_PATH=`dirname "$KARAF_SERVICE_PIDFILE"`
|
||||
mkdir -p "$PID_PATH"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$PID_PATH" || true
|
||||
|
||||
if [ ! -z "$KARAF_SERVICE_USER" ]; then
|
||||
if [ "$KARAF_SERVICE_USER" = "root" ]; then
|
||||
KARAF_EXEC=exec
|
||||
export KARAF_EXEC
|
||||
|
||||
JAVA_HOME=$JAVA_HOME
|
||||
export JAVA_HOME
|
||||
|
||||
"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE" daemon >> "$KARAF_SERVICE_LOG" 2>&1 &
|
||||
|
||||
echo $! > "$KARAF_SERVICE_PIDFILE"
|
||||
else
|
||||
su - $KARAF_SERVICE_USER \
|
||||
-c " { export KARAF_EXEC=exec; export JAVA_HOME=$JAVA_HOME; \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" daemon >> \"$KARAF_SERVICE_LOG\" 2>&1 & } ; echo \$! >| \"$KARAF_SERVICE_PIDFILE\" "
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$KARAF_SERVICE_PIDFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
RETVAL=$?
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
do_stop() {
|
||||
echo $"Stopping $prog: "
|
||||
count=0;
|
||||
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read kpid < "$KARAF_SERVICE_PIDFILE"
|
||||
kwait=$SHUTDOWN_WAIT
|
||||
|
||||
if [ "$KARAF_SERVICE_USER" = "root" ]; then
|
||||
JAVA_HOME=$JAVA_HOME
|
||||
export JAVA_HOME
|
||||
|
||||
"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE" stop >> "$KARAF_SERVICE_LOG" 2>&1
|
||||
else
|
||||
su - $KARAF_SERVICE_USER \
|
||||
-c "export JAVA_HOME=$JAVA_HOME; \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" stop >> \"$KARAF_SERVICE_LOG\" 2>&1"
|
||||
fi
|
||||
|
||||
until [ `ps -p $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
|
||||
do
|
||||
sleep 1
|
||||
count=`expr $count + 1`
|
||||
done
|
||||
|
||||
if [ $count -gt $kwait ]; then
|
||||
if [ `ps -p $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '1' ]; then
|
||||
kill -9 $kpid
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$KARAF_SERVICE_PIDFILE"
|
||||
rm -f $KARAF_LOCKFILE
|
||||
}
|
||||
|
||||
do_status() {
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read ppid < "$KARAF_SERVICE_PIDFILE"
|
||||
if [ `ps -p $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
|
||||
echo "$prog is running (pid $ppid)"
|
||||
return 0
|
||||
else
|
||||
echo "$prog dead but pid file exists"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
echo "$prog is not running"
|
||||
return 3
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
do_start
|
||||
;;
|
||||
stop)
|
||||
do_stop
|
||||
;;
|
||||
restart)
|
||||
do_stop
|
||||
do_start
|
||||
;;
|
||||
status)
|
||||
do_status
|
||||
;;
|
||||
*)
|
||||
## If no parameters are given, print which are avaiable.
|
||||
echo "Usage: $0 {start|stop|status|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
246
runtime/bin/contrib/karaf-service-template.init-debian
Normal file
246
runtime/bin/contrib/karaf-service-template.init-debian
Normal file
@@ -0,0 +1,246 @@
|
||||
#!/bin/sh
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
# /etc/init.d/${KARAF_SERVICE_NAME} -- startup script for Karaf
|
||||
#
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ${KARAF_SERVICE_NAME}
|
||||
# Required-Start: $remote_fs $network
|
||||
# Required-Stop: $remote_fs $network
|
||||
# Should-Start: $named
|
||||
# Should-Stop: $named
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Karaf
|
||||
# Description: Provide Karaf startup/shutdown script
|
||||
### END INIT INFO
|
||||
|
||||
NAME=${KARAF_SERVICE_NAME}
|
||||
DESC=${KARAF_SERVICE_NAME}
|
||||
DEFAULT="/etc/default/$NAME"
|
||||
|
||||
# Check privileges
|
||||
if [ `id -u` -ne 0 ]; then
|
||||
echo "You need root privileges to run this script"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure karaf is started with system locale
|
||||
if [ -r /etc/default/locale ]; then
|
||||
. /etc/default/locale
|
||||
export LANG
|
||||
fi
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -r /etc/default/rcS ]; then
|
||||
. /etc/default/rcS
|
||||
fi
|
||||
|
||||
# Overwrite settings from default file
|
||||
if [ -f "$DEFAULT" ]; then
|
||||
. "$DEFAULT"
|
||||
fi
|
||||
|
||||
if [ -r "${KARAF_SERVICE_CONF}" ]; then
|
||||
. "${KARAF_SERVICE_CONF}"
|
||||
else
|
||||
echo "Error KARAF_SERVICE_CONF not defined"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Location of JDK
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
export JAVA_HOME
|
||||
fi
|
||||
|
||||
# Setup the JVM
|
||||
if [ -z "$JAVA" ]; then
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA="$JAVA_HOME/bin/java"
|
||||
else
|
||||
JAVA="java"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check karaf user
|
||||
id $KARAF_SERVICE_USER > /dev/null 2>&1
|
||||
if [ $? -ne 0 -o -z "$KARAF_SERVICE_USER" ]; then
|
||||
echo "User \"$KARAF_SERVICE_USER\" does not exist..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check owner of KARAF_SERVICE_PATH
|
||||
if [ ! $(stat -L -c "%U" "$KARAF_SERVICE_PATH") = $KARAF_SERVICE_USER ]; then
|
||||
echo "The user \"$KARAF_SERVICE_USER\" is not owner of \"$KARAF_SERVICE_PATH\"" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The amount of time to wait for startup
|
||||
if [ -z "$STARTUP_WAIT" ]; then
|
||||
STARTUP_WAIT=30
|
||||
fi
|
||||
|
||||
# The amount of time to wait for shutdown
|
||||
if [ -z "$SHUTDOWN_WAIT" ]; then
|
||||
SHUTDOWN_WAIT=30
|
||||
fi
|
||||
|
||||
|
||||
# Helper function to check status of karaf service
|
||||
check_status() {
|
||||
pidofproc -p "$KARAF_SERVICE_PIDFILE" "$JAVA" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting $DESC" "$NAME"
|
||||
|
||||
# PID file
|
||||
PID_PATH=$(dirname "$KARAF_SERVICE_PIDFILE")
|
||||
if [ ! -d "$PID_PATH" ]; then
|
||||
mkdir -p "$PID_PATH"
|
||||
fi
|
||||
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$PID_PATH" || true
|
||||
|
||||
# Console log
|
||||
LOG_PATH=$(dirname "$KARAF_SERVICE_LOG")
|
||||
|
||||
if [ ! -d "$LOG_PATH" ]; then
|
||||
mkdir -p "$LOG_PATH"
|
||||
fi
|
||||
|
||||
cat /dev/null > "$KARAF_SERVICE_LOG"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$LOG_PATH"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$KARAF_SERVICE_LOG"
|
||||
|
||||
start-stop-daemon \
|
||||
--start \
|
||||
--user "$KARAF_SERVICE_USER" \
|
||||
--chuid "$KARAF_SERVICE_USER" \
|
||||
--chdir "$KARAF_SERVICE_PATH" \
|
||||
--pidfile "$KARAF_SERVICE_PIDFILE" \
|
||||
--make-pidfile \
|
||||
--exec "$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE" -- "daemon" \
|
||||
>> "$KARAF_SERVICE_LOG" 2>&1 &
|
||||
|
||||
count=0
|
||||
launched=0
|
||||
until [ $count -gt $STARTUP_WAIT ]
|
||||
do
|
||||
sleep 1
|
||||
count=$((count + 1));
|
||||
if check_status; then
|
||||
launched=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if check_status; then
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg 1
|
||||
fi
|
||||
|
||||
if [ $launched -eq 0 ]; then
|
||||
log_warning_msg "$DESC hasn't started within the timeout allowed"
|
||||
log_warning_msg "please review file \"$KARAF_SERVICE_LOG\" to see the status of the service"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
check_status
|
||||
status_stop=$?
|
||||
if [ $status_stop -eq 0 ]; then
|
||||
kwait=$SHUTDOWN_WAIT
|
||||
read kpid < "$KARAF_SERVICE_PIDFILE"
|
||||
log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
|
||||
children_pids=$(pgrep -P $kpid)
|
||||
|
||||
su - $KARAF_SERVICE_USER \
|
||||
-c "export JAVA_HOME=$JAVA_HOME; \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" stop"
|
||||
|
||||
count=0
|
||||
until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
|
||||
do
|
||||
sleep 1
|
||||
count=$((count + 1));
|
||||
done
|
||||
|
||||
if check_status; then
|
||||
start-stop-daemon \
|
||||
--stop \
|
||||
--quiet \
|
||||
--pidfile "$KARAF_SERVICE_PIDFILE" \
|
||||
--user "$KARAF_SERVICE_USER" \
|
||||
--retry=TERM/$SHUTDOWN_WAIT/KILL/5 \
|
||||
> /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 2 ]; then
|
||||
log_failure_msg "$DESC can't be stopped"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
for child in $children_pids; do
|
||||
/bin/kill -9 $child >/dev/null 2>&1
|
||||
done
|
||||
|
||||
log_end_msg 0
|
||||
|
||||
rm -rf "$KARAF_SERVICE_PIDFILE"
|
||||
elif [ $status_stop -eq 1 ]; then
|
||||
log_action_msg "$DESC is not running but the pid file exists, cleaning up"
|
||||
rm -f "$KARAF_SERVICE_PIDFILE"
|
||||
elif [ $status_stop -eq 3 ]; then
|
||||
log_action_msg "$DESC is not running"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
check_status
|
||||
status_restart=$?
|
||||
if [ $status_restart -eq 0 ]; then
|
||||
$0 stop
|
||||
fi
|
||||
$0 start
|
||||
;;
|
||||
status)
|
||||
check_status
|
||||
status=$?
|
||||
if [ $status -eq 0 ]; then
|
||||
read pid < $KARAF_SERVICE_PIDFILE
|
||||
log_action_msg "$DESC is running with pid $pid"
|
||||
exit 0
|
||||
elif [ $status -eq 1 ]; then
|
||||
log_action_msg "$DESC is not running and the pid file exists"
|
||||
exit 1
|
||||
elif [ $status -eq 3 ]; then
|
||||
log_action_msg "$DESC is not running"
|
||||
exit 3
|
||||
else
|
||||
log_action_msg "Unable to determine $DESC status"
|
||||
exit 4
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
log_action_msg "Usage: $0 {start|stop|restart|status}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
164
runtime/bin/contrib/karaf-service-template.init-redhat
Normal file
164
runtime/bin/contrib/karaf-service-template.init-redhat
Normal file
@@ -0,0 +1,164 @@
|
||||
#!/bin/sh
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
# Karaf control script
|
||||
#
|
||||
# chkconfig: - 80 20
|
||||
# description: Karaf startup script
|
||||
# processname: ${KARAF_SERVICE_NAME}
|
||||
# pidfile: ${KARAF_SERVICE_PIDFILE}
|
||||
# config: ${KARAF_SERVICE_CONF}
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. /etc/init.d/functions
|
||||
|
||||
# Load Java configuration.
|
||||
[ -r /etc/java/java.conf ] && . /etc/java/java.conf
|
||||
export JAVA_HOME
|
||||
|
||||
if [ -r "${KARAF_SERVICE_CONF}" ]; then
|
||||
. "${KARAF_SERVICE_CONF}"
|
||||
else
|
||||
echo "Error KARAF_SERVICE_CONF not defined"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ -z "$STARTUP_WAIT" ]; then
|
||||
STARTUP_WAIT=30
|
||||
fi
|
||||
|
||||
if [ -z "$SHUTDOWN_WAIT" ]; then
|
||||
SHUTDOWN_WAIT=30
|
||||
fi
|
||||
|
||||
prog=${KARAF_SERVICE_NAME}
|
||||
currenttime=$(date +%s%N | cut -b1-13)
|
||||
|
||||
start() {
|
||||
echo -n "Starting $prog: "
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read ppid < "$KARAF_SERVICE_PIDFILE"
|
||||
if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
|
||||
echo -n "$prog is already running"
|
||||
failure
|
||||
echo
|
||||
return 1
|
||||
else
|
||||
rm -f "$KARAF_SERVICE_PIDFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
LOG_PATH=`dirname "$KARAF_SERVICE_LOG"`
|
||||
mkdir -p "$LOG_PATH"
|
||||
cat /dev/null > "$KARAF_SERVICE_LOG"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$KARAF_SERVICE_LOG"
|
||||
|
||||
PID_PATH=`dirname "$KARAF_SERVICE_PIDFILE"`
|
||||
mkdir -p "$PID_PATH"
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$PID_PATH" || true
|
||||
|
||||
if [ ! -z "$KARAF_SERVICE_USER" ]; then
|
||||
if [ -r /etc/rc.d/init.d/functions ]; then
|
||||
daemon \
|
||||
--user="$KARAF_SERVICE_USER" \
|
||||
--pidfile="$KARAF_SERVICE_PIDFILE" \
|
||||
" { \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" daemon >> \"$KARAF_SERVICE_LOG\" 2>&1 & } ; echo \$! >| \"$KARAF_SERVICE_PIDFILE\" "
|
||||
else
|
||||
su - $KARAF_SERVICE_USER \
|
||||
-c " { \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" daemon >> \"$KARAF_SERVICE_LOG\" 2>&1 & } ; echo \$! >| \"$KARAF_SERVICE_PIDFILE\" "
|
||||
fi
|
||||
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
chown $KARAF_SERVICE_USER:$KARAF_SERVICE_GROUP "$KARAF_SERVICE_PIDFILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
RETVAL=$?
|
||||
echo
|
||||
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
touch $KARAF_LOCKFILE
|
||||
fi
|
||||
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog: "
|
||||
count=0;
|
||||
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read kpid < "$KARAF_SERVICE_PIDFILE"
|
||||
let kwait=$SHUTDOWN_WAIT
|
||||
|
||||
# Try issuing SIGTERM
|
||||
su - $KARAF_SERVICE_USER \
|
||||
-c "export JAVA_HOME=$JAVA_HOME; \"$KARAF_SERVICE_PATH/bin/$KARAF_SERVICE_EXECUTABLE\" stop"
|
||||
|
||||
until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ]
|
||||
do
|
||||
sleep 1
|
||||
let count=$count+1;
|
||||
done
|
||||
|
||||
if [ $count -gt $kwait ]; then
|
||||
kill -9 $kpid
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$KARAF_SERVICE_PIDFILE"
|
||||
rm -f "$KARAF_LOCKFILE"
|
||||
|
||||
success
|
||||
echo
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -f "$KARAF_SERVICE_PIDFILE" ]; then
|
||||
read ppid < "$KARAF_SERVICE_PIDFILE"
|
||||
if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then
|
||||
echo "$prog is running (pid $ppid)"
|
||||
return 0
|
||||
else
|
||||
echo "$prog dead but pid file exists"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
echo "$prog is not running"
|
||||
return 3
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
## If no parameters are given, print which are avaiable.
|
||||
echo "Usage: $0 {start|stop|status|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
94
runtime/bin/contrib/karaf-service-template.solaris-smf
Normal file
94
runtime/bin/contrib/karaf-service-template.solaris-smf
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE service_bundle
|
||||
SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
|
||||
|
||||
<service_bundle type="manifest" name="application/${KARAF_SERVICE_NAME}">
|
||||
<service version="1" type="service" name="application/${KARAF_SERVICE_NAME}">
|
||||
|
||||
<create_default_instance enabled='false' />
|
||||
<single_instance />
|
||||
|
||||
<dependency
|
||||
restart_on="none"
|
||||
type="service"
|
||||
name="multi_user_dependency"
|
||||
grouping="require_all">
|
||||
|
||||
<service_fmri value="svc:/milestone/multi-user"/>
|
||||
</dependency>
|
||||
|
||||
<method_context>
|
||||
<method_credential user='${KARAF_SERVICE_USER}' group='${KARAF_SERVICE_GROUP}'/>
|
||||
<method_environment>
|
||||
<envvar name="JAVA_HOME" value="${JAVA_HOME}"/>
|
||||
</method_environment>
|
||||
</method_context>
|
||||
|
||||
<!-- *************************************************************** -->
|
||||
<!-- STOP/START -->
|
||||
<!-- *************************************************************** -->
|
||||
|
||||
<exec_method
|
||||
timeout_seconds="60"
|
||||
type="method"
|
||||
name="start"
|
||||
exec="${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} daemon &">
|
||||
</exec_method>
|
||||
|
||||
<exec_method
|
||||
timeout_seconds="60"
|
||||
type="method"
|
||||
name="stop"
|
||||
exec="${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} stop">
|
||||
</exec_method>
|
||||
|
||||
<!-- *************************************************************** -->
|
||||
<!-- -->
|
||||
<!-- *************************************************************** -->
|
||||
|
||||
<!-- do not restart the service in case of errors -->
|
||||
<property_group name='startd' type='framework'>
|
||||
<propval name='duration'
|
||||
type='astring'
|
||||
value='transient'/>
|
||||
<propval name='ignore_error'
|
||||
type='astring'
|
||||
value='core,signal'/>
|
||||
</property_group>
|
||||
|
||||
<stability value='Evolving' />
|
||||
|
||||
<template>
|
||||
<common_name>
|
||||
<loctext xml:lang="C">
|
||||
${KARAF_SERVICE_NAME}
|
||||
</loctext>
|
||||
</common_name>
|
||||
<description>
|
||||
<loctext xml:lang="C">
|
||||
${KARAF_SERVICE_NAME}
|
||||
</loctext>
|
||||
</description>
|
||||
</template>
|
||||
|
||||
</service>
|
||||
</service_bundle>
|
||||
|
||||
39
runtime/bin/contrib/karaf-service-template.systemd
Normal file
39
runtime/bin/contrib/karaf-service-template.systemd
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
[Unit]
|
||||
Description=Karaf - ${KARAF_SERVICE_NAME}
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=${KARAF_SERVICE_CONF}
|
||||
|
||||
ExecStart=${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} daemon
|
||||
ExecStop=${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} stop
|
||||
|
||||
User=${KARAF_SERVICE_USER}
|
||||
Group=${KARAF_SERVICE_GROUP}
|
||||
|
||||
SuccessExitStatus=0 143
|
||||
RestartSec=15
|
||||
Restart=on-failure
|
||||
|
||||
LimitNOFILE=102642
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
42
runtime/bin/contrib/karaf-service-template.systemd-instances
Normal file
42
runtime/bin/contrib/karaf-service-template.systemd-instances
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
[Unit]
|
||||
Description=Karaf - ${KARAF_SERVICE_NAME} - %i
|
||||
After=syslog.target network.target
|
||||
Requires=${KARAF_SERVICE_NAME}.service
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-${KARAF_SERVICE_PATH}/etc/${KARAF_SERVICE_NAME}-%i.conf
|
||||
EnvironmentFile=-${KARAF_SERVICE_PATH}/instances/%i/etc/${KARAF_SERVICE_NAME}.conf
|
||||
Environment=KARAF_HOME=${KARAF_SERVICE_PATH}
|
||||
Environment=KARAF_BASE=${KARAF_SERVICE_PATH}/instances/%i
|
||||
|
||||
ExecStart=${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} daemon
|
||||
ExecStop=${KARAF_SERVICE_PATH}/bin/${KARAF_SERVICE_EXECUTABLE} stop
|
||||
|
||||
User=${KARAF_SERVICE_USER}
|
||||
Group=${KARAF_SERVICE_GROUP}
|
||||
|
||||
SuccessExitStatus=0 1 143
|
||||
RestartSec=15
|
||||
Restart=on-failure
|
||||
|
||||
LimitNOFILE=102642
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
BIN
runtime/bin/contrib/karaf-service-win.exe
Normal file
BIN
runtime/bin/contrib/karaf-service-win.exe
Normal file
Binary file not shown.
50
runtime/bin/contrib/karaf-service-win.xml
Normal file
50
runtime/bin/contrib/karaf-service-win.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<service>
|
||||
|
||||
<!--
|
||||
This script is provided as a template you can quckly customize by replacing
|
||||
the following variables:
|
||||
|
||||
KARAF_SERVICE_NAME
|
||||
KARAF_SERVICE_PATH
|
||||
KARAF_SERVICE_EXECUTABLE
|
||||
|
||||
For a detailed overview of the confguration options, please visit winsw home
|
||||
page (https://github.com/kohsuke/winsw)
|
||||
-->
|
||||
|
||||
<id>%KARAF_SERVICE_NAME%</id>
|
||||
<name>%KARAF_SERVICE_NAME%</name>
|
||||
<description>Apache Karaf %KARAF_SERVICE_NAME%</description>
|
||||
|
||||
<!-- start -->
|
||||
<executable>%KARAF_SERVICE_PATH%\bin\%KARAF_SERVICE_EXECUTABLE%</executable>
|
||||
<startargument>daemon</startargument>
|
||||
|
||||
<!-- stop -->
|
||||
<stopexecutable>%KARAF_SERVICE_PATH%\bin\%KARAF_SERVICE_EXECUTABLE%</stopexecutable>
|
||||
<stopargument>stop</stopargument>
|
||||
<stoptimeout>10sec</stoptimeout>
|
||||
|
||||
<!-- logging -->
|
||||
<logpath>%KARAF_SERVICE_PATH%\data\log</logpath>
|
||||
<log mode="roll-by-time">
|
||||
<pattern>yyyyMMdd</pattern>
|
||||
</log>
|
||||
|
||||
</service>
|
||||
206
runtime/bin/contrib/karaf-service.sh
Normal file
206
runtime/bin/contrib/karaf-service.sh
Normal file
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
function usage {
|
||||
cat <<-END >&2
|
||||
USAGE: $0
|
||||
-k KARAF_SERVICE_PATH # Karaf installation path
|
||||
-d KARAF_SERVICE_DATA # Karaf data path (default to \${KARAF_SERVICE_PATH}/data)
|
||||
-c KARAF_SERVICE_CONF # Karaf configuration file (default to \${KARAF_SERVICE_PATH/etc/\${KARAF_SERVICE_NAME}.conf
|
||||
-t KARAF_SERVICE_ETC # Karaf etc path (default to \${KARAF_SERVICE_PATH/etc}
|
||||
-p KARAF_SERVICE_PIDFILE # Karaf pid path (default to \${KARAF_SERVICE_DATA}/\${KARAF_SERVICE_NAME}.pid)
|
||||
-n KARAF_SERVICE_NAME # Karaf service name (default karaf)
|
||||
-e KARAF_ENV # Karaf environment variable (can be repeated)
|
||||
-u KARAF_SERVICE_USER # Karaf user
|
||||
-g KARAF_SERVICE_GROUP # Karaf group (default \${KARAF_SERVICE_USER)
|
||||
-l KARAF_SERVICE_LOG # Karaf console log (default to \${KARAF_SERVICE_DATA}/log/\${KARAF_SERVICE_NAME}-console.log)
|
||||
-f KARAF_SERVICE_TEMPLATE # Template file to use
|
||||
-x KARAF_SERVICE_EXECUTABLE # Karaf executable name (defaul karaf, should support daemon and stop commands)
|
||||
-h # this usage message
|
||||
END
|
||||
exit
|
||||
}
|
||||
|
||||
CONF_TEMPLATE="karaf-service-template.conf"
|
||||
SYSTEMD_TEMPLATE="karaf-service-template.systemd"
|
||||
SYSTEMD_TEMPLATE_INSTANCES="karaf-service-template.systemd-instances"
|
||||
INIT_TEMPLATE="karaf-service-template.init"
|
||||
INIT_REDHAT_TEMPLATE="karaf-service-template.init-redhat"
|
||||
INIT_DEBIAN_TEMPLATE="karaf-service-template.init-debian"
|
||||
SOLARIS_SMF_TEMPLATE="karaf-service-template.solaris-smf"
|
||||
|
||||
################################################################################
|
||||
#
|
||||
################################################################################
|
||||
|
||||
KARAF_ENV=()
|
||||
|
||||
while getopts k:d:c:p:n:u:g:l:t:e:f:x:h opt
|
||||
do
|
||||
case $opt in
|
||||
k) export KARAF_SERVICE_PATH="$OPTARG" ;;
|
||||
d) export KARAF_SERVICE_DATA="$OPTARG" ;;
|
||||
c) export KARAF_SERVICE_CONF="$OPTARG" ;;
|
||||
p) export KARAF_SERVICE_PIDFILE="$OPTARG" ;;
|
||||
n) export KARAF_SERVICE_NAME="$OPTARG" ;;
|
||||
u) export KARAF_SERVICE_USER="$OPTARG" ;;
|
||||
g) export KARAF_SERVICE_GROUP="$OPTARG" ;;
|
||||
l) export KARAF_SERVICE_LOG="$OPTARG" ;;
|
||||
t) export KARAF_SERVICE_ETC="$OPTARG" ;;
|
||||
f) export KARAF_SERVICE_TEMPLATE="$OPTARG" ;;
|
||||
x) export KARAF_SERVICE_EXECUTABLE="$OPTARG" ;;
|
||||
e) KARAF_ENV+=("$OPTARG") ;;
|
||||
h|?) usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if [[ ! $KARAF_SERVICE_PATH ]]; then
|
||||
echo "Warning, KARAF_SERVICE_PATH is required"
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_DATA ]]; then
|
||||
export KARAF_SERVICE_DATA="${KARAF_SERVICE_PATH}/data"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_ETC ]]; then
|
||||
export KARAF_SERVICE_ETC="${KARAF_SERVICE_PATH}/etc"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_NAME ]]; then
|
||||
export KARAF_SERVICE_NAME="karaf"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_CONF ]]; then
|
||||
export KARAF_SERVICE_CONF="${KARAF_SERVICE_PATH}/etc/${KARAF_SERVICE_NAME}.conf"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_PIDFILE ]]; then
|
||||
export KARAF_SERVICE_PIDFILE="${KARAF_SERVICE_DATA}/${KARAF_SERVICE_NAME}.pid"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_LOG ]]; then
|
||||
export KARAF_SERVICE_LOG="${KARAF_SERVICE_DATA}/log/${KARAF_SERVICE_NAME}-console.log"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_USER ]]; then
|
||||
export KARAF_SERVICE_USER="root"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_GROUP ]]; then
|
||||
export KARAF_SERVICE_GROUP="${KARAF_SERVICE_USER}"
|
||||
fi
|
||||
|
||||
if [[ ! $KARAF_SERVICE_EXECUTABLE ]]; then
|
||||
export KARAF_SERVICE_EXECUTABLE="karaf"
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
#
|
||||
################################################################################
|
||||
|
||||
function generate_service_descriptor {
|
||||
echo "Writing service file \"$2\""
|
||||
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' < "$1" > "$2"
|
||||
|
||||
if [ $# -eq 4 ]; then
|
||||
echo "Writing service configuration file \"$4\""
|
||||
perl -p -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' < "$3" > "$4"
|
||||
|
||||
for var in "${KARAF_ENV[@]}"; do
|
||||
echo "${var}" >> "$4"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
#
|
||||
################################################################################
|
||||
|
||||
if [[ ! $KARAF_SERVICE_TEMPLATE ]]; then
|
||||
case $(uname | tr [:upper:] [:lower:]) in
|
||||
sunos)
|
||||
# add KARAF_ENV vars to envirioment
|
||||
for var in "${KARAF_ENV[@]}"; do
|
||||
export $var
|
||||
done
|
||||
|
||||
# Default java path if not set
|
||||
if [[ ! $JAVA_HOME ]]; then
|
||||
export JAVA_HOME=/usr/java
|
||||
fi
|
||||
|
||||
# escape spaces in path
|
||||
export KARAF_SERVICE_PATH="$(echo $KARAF_SERVICE_PATH | sed 's/ /\\ /g')"
|
||||
export KARAF_SERVICE_DATA="$(echo $KARAF_SERVICE_DATA | sed 's/ /\\ /g')"
|
||||
export KARAF_SERVICE_CONF="$(echo $KARAF_SERVICE_CONF | sed 's/ /\\ /g')"
|
||||
export KARAF_SERVICE_PIDFILE="$(echo $KARAF_SERVICE_PIDFILE | sed 's/ /\\ /g')"
|
||||
|
||||
generate_service_descriptor \
|
||||
"$SOLARIS_SMF_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}.xml"
|
||||
;;
|
||||
linux)
|
||||
if [ -d /run/systemd/system ]; then
|
||||
generate_service_descriptor \
|
||||
"$SYSTEMD_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}.service" \
|
||||
"${CONF_TEMPLATE}" \
|
||||
"${KARAF_SERVICE_CONF}"
|
||||
|
||||
generate_service_descriptor \
|
||||
"$SYSTEMD_TEMPLATE_INSTANCES" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}@.service"
|
||||
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
generate_service_descriptor \
|
||||
"$INIT_REDHAT_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}" \
|
||||
"${CONF_TEMPLATE}" \
|
||||
"${KARAF_SERVICE_CONF}"
|
||||
|
||||
chmod 755 "${PWD}/${KARAF_SERVICE_NAME}"
|
||||
elif [ -f /etc/debian-release ] || [ -f /etc/debian_version ]; then
|
||||
generate_service_descriptor \
|
||||
"$INIT_DEBIAN_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}" \
|
||||
"${CONF_TEMPLATE}" \
|
||||
"${KARAF_SERVICE_CONF}"
|
||||
|
||||
chmod 755 "${PWD}/${KARAF_SERVICE_NAME}"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
generate_service_descriptor \
|
||||
"$INIT_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}" \
|
||||
"${CONF_TEMPLATE}" \
|
||||
"${KARAF_SERVICE_CONF}"
|
||||
|
||||
chmod 755 "${PWD}/${KARAF_SERVICE_NAME}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
generate_service_descriptor \
|
||||
"$KARAF_SERVICE_TEMPLATE" \
|
||||
"${PWD}/${KARAF_SERVICE_NAME}" \
|
||||
"${CONF_TEMPLATE}" \
|
||||
"${KARAF_SERVICE_CONF}"
|
||||
fi
|
||||
321
runtime/bin/inc
Normal file
321
runtime/bin/inc
Normal file
@@ -0,0 +1,321 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
warn() {
|
||||
echo "${PROGNAME}: $*"
|
||||
}
|
||||
|
||||
die() {
|
||||
warn "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
detectOS() {
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false;
|
||||
mingw=false;
|
||||
darwin=false;
|
||||
aix=false;
|
||||
os400=false;
|
||||
hpux=false;
|
||||
solaris=false;
|
||||
case "$(uname)" in
|
||||
CYGWIN*)
|
||||
cygwin=true
|
||||
;;
|
||||
MINGW*)
|
||||
mingw=true
|
||||
;;
|
||||
Darwin*)
|
||||
darwin=true
|
||||
;;
|
||||
AIX*)
|
||||
aix=true
|
||||
# For AIX, set an environment variable
|
||||
export LDR_CNTRL=MAXDATA=0xB0000000@DSA
|
||||
echo ${LDR_CNTRL}
|
||||
;;
|
||||
OS400*)
|
||||
os400=true
|
||||
;;
|
||||
HP-UX*)
|
||||
hpux=true
|
||||
# For HP-UX, set an environment variable
|
||||
export PS_PREFIX="UNIX95= "
|
||||
echo "${PS_PREFIX}"
|
||||
;;
|
||||
SunOS*)
|
||||
solaris=true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
unlimitFD() {
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that
|
||||
if [ "x${MAX_FD}" = "x" ]; then
|
||||
MAX_FD="maximum"
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can
|
||||
if [ "x$(command -v ulimit)" != "x" ] && [ "${os400}" = "false" ] ; then
|
||||
if [ "${MAX_FD}" = "maximum" ] || [ "${MAX_FD}" = "max" ]; then
|
||||
MAX_FD_LIMIT=$(ulimit -H -n)
|
||||
if [ $? -eq 0 ]; then
|
||||
# use the system max
|
||||
MAX_FD="${MAX_FD_LIMIT}"
|
||||
else
|
||||
warn "Could not query system maximum file descriptor limit: ${MAX_FD_LIMIT}"
|
||||
fi
|
||||
fi
|
||||
if [ "${MAX_FD}" != 'unlimited' ]; then
|
||||
ulimit -n "${MAX_FD}" > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
warn "Could not set maximum file descriptor limit: ${MAX_FD}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
locateHome() {
|
||||
if [ "x${KARAF_HOME}" != "x" ]; then
|
||||
warn "Ignoring predefined value for KARAF_HOME"
|
||||
unset KARAF_HOME
|
||||
fi
|
||||
if [ "x${KARAF_HOME}" = "x" ]; then
|
||||
# In POSIX shells, CDPATH may cause cd to write to stdout
|
||||
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
|
||||
# KARAF_HOME is not provided, fall back to default
|
||||
KARAF_HOME=$(cd "${DIRNAME}/.." || exit 2; pwd)
|
||||
fi
|
||||
|
||||
if [ ! -d "${KARAF_HOME}" ]; then
|
||||
die "KARAF_HOME is not valid: ${KARAF_HOME}"
|
||||
fi
|
||||
}
|
||||
|
||||
locateBase() {
|
||||
if [ "x${KARAF_BASE}" != "x" ]; then
|
||||
if [ ! -d "${KARAF_BASE}" ]; then
|
||||
die "KARAF_BASE is not valid: ${KARAF_BASE}"
|
||||
fi
|
||||
else
|
||||
KARAF_BASE=${KARAF_HOME}
|
||||
fi
|
||||
}
|
||||
|
||||
locateData() {
|
||||
if [ "x${KARAF_DATA}" != "x" ]; then
|
||||
if [ ! -d "${KARAF_DATA}" ]; then
|
||||
die "KARAF_DATA is not valid: ${KARAF_DATA}"
|
||||
fi
|
||||
else
|
||||
KARAF_DATA=${KARAF_BASE}/data
|
||||
fi
|
||||
}
|
||||
|
||||
locateEtc() {
|
||||
if [ "x${KARAF_ETC}" != "x" ]; then
|
||||
if [ ! -d "${KARAF_ETC}" ]; then
|
||||
die "KARAF_ETC is not valid: ${KARAF_ETC}"
|
||||
fi
|
||||
else
|
||||
KARAF_ETC=${KARAF_BASE}/etc
|
||||
fi
|
||||
}
|
||||
|
||||
setupNativePath() {
|
||||
# Support for loading native libraries
|
||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${KARAF_BASE}/lib:${KARAF_HOME}/lib"
|
||||
|
||||
# For Cygwin, set PATH from LD_LIBRARY_PATH
|
||||
if ${cygwin}; then
|
||||
LD_LIBRARY_PATH=$(cygpath --path --windows "${LD_LIBRARY_PATH}")
|
||||
PATH="${PATH};${LD_LIBRARY_PATH}"
|
||||
export PATH
|
||||
fi
|
||||
export LD_LIBRARY_PATH
|
||||
}
|
||||
|
||||
pathCanonical() {
|
||||
dst="${1}"
|
||||
while [ -h "${dst}" ] ; do
|
||||
ls=$(ls -ld "${dst}")
|
||||
link=$(expr "${ls}" : '.*-> \(.*\)$')
|
||||
if expr "${link}" : '/.*' > /dev/null; then
|
||||
dst="${link}"
|
||||
else
|
||||
dst="$(dirname "${dst}")/${link}"
|
||||
fi
|
||||
done
|
||||
bas=$(basename "${dst}")
|
||||
dir=$(dirname "${dst}")
|
||||
if [ "${bas}" != "${dir}" ]; then
|
||||
dst="$(pathCanonical "${dir}")/${bas}"
|
||||
fi
|
||||
echo "${dst}" | sed -e 's#//#/#g' -e 's#/./#/#g' -e 's#/[^/]*/../#/#g'
|
||||
}
|
||||
|
||||
locateJava() {
|
||||
# Setup the Java Virtual Machine
|
||||
if ${cygwin} ; then
|
||||
[ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")
|
||||
[ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")
|
||||
fi
|
||||
|
||||
if [ "x${JAVA_HOME}" = "x" ] && [ "${darwin}" = "true" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
|
||||
fi
|
||||
if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
if [ "x${JAVA}" = "x" ]; then
|
||||
if [ "x${JAVA_HOME}" != "x" ]; then
|
||||
if [ ! -d "${JAVA_HOME}" ]; then
|
||||
die "JAVA_HOME is not valid: ${JAVA_HOME}"
|
||||
fi
|
||||
JAVA="${JAVA_HOME}/bin/java"
|
||||
else
|
||||
warn "JAVA_HOME not set; results may vary"
|
||||
JAVA=$(command -v java)
|
||||
if [ "x${JAVA}" = "x" ]; then
|
||||
die "java command not found"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "x${JAVA_HOME}" = "x" ]; then
|
||||
JAVA_HOME="$(dirname "$(dirname "$(pathCanonical "${JAVA}")")")"
|
||||
fi
|
||||
}
|
||||
|
||||
detectJVM() {
|
||||
# This service should call $(java -version),
|
||||
# read stdout, and look for hints
|
||||
if "${JAVA}" -version 2>&1 | grep "^IBM" ; then
|
||||
JVM_VENDOR="IBM"
|
||||
# on OS/400, java -version does not contain IBM explicitly
|
||||
elif ${os400}; then
|
||||
JVM_VENDOR="IBM"
|
||||
else
|
||||
JVM_VENDOR="SUN"
|
||||
fi
|
||||
# echo "JVM vendor is ${JVM_VENDOR}"
|
||||
}
|
||||
|
||||
checkJvmVersion() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
VERSION=$("${JAVA}" -version 2>&1 | ${AWK} -F '"' '/version/ {print $2}' | sed -e 's/_.*//g; s/^1\.//g; s/\..*//g; s/-.*//g;')
|
||||
|
||||
# java must be at least version 8
|
||||
if [ "${VERSION}" -lt "8" ]; then
|
||||
die "JVM must be greater than 1.8"
|
||||
fi
|
||||
}
|
||||
|
||||
setupDebugOptions() {
|
||||
if [ "x${JAVA_OPTS}" = "x" ]; then
|
||||
JAVA_OPTS="${DEFAULT_JAVA_OPTS}"
|
||||
fi
|
||||
export JAVA_OPTS
|
||||
|
||||
if [ "x${EXTRA_JAVA_OPTS}" != "x" ]; then
|
||||
JAVA_OPTS="${JAVA_OPTS} ${EXTRA_JAVA_OPTS}"
|
||||
fi
|
||||
|
||||
# Set Debug options if enabled
|
||||
if [ "x${KARAF_DEBUG}" != "x" ]; then
|
||||
# Use the defaults if JAVA_DEBUG_OPTS was not set
|
||||
if [ "x${JAVA_DEBUG_OPTS}" = "x" ]; then
|
||||
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUG_OPTS}"
|
||||
fi
|
||||
|
||||
JAVA_OPTS="${JAVA_DEBUG_OPTS} ${JAVA_OPTS}"
|
||||
warn "Enabling Java debug options: ${JAVA_DEBUG_OPTS}"
|
||||
fi
|
||||
}
|
||||
|
||||
setupDefaults() {
|
||||
#
|
||||
# Set up some easily accessible MIN/MAX params for JVM mem usage
|
||||
#
|
||||
if [ "x${JAVA_MIN_MEM}" = "x" ]; then
|
||||
JAVA_MIN_MEM=128M
|
||||
export JAVA_MIN_MEM
|
||||
fi
|
||||
if [ "x${JAVA_MAX_MEM}" = "x" ]; then
|
||||
JAVA_MAX_MEM=512M
|
||||
export JAVA_MAX_MEM
|
||||
fi
|
||||
|
||||
DEFAULT_JAVA_OPTS="-Xms${JAVA_MIN_MEM} -Xmx${JAVA_MAX_MEM} -XX:+UnlockDiagnosticVMOptions "
|
||||
|
||||
#Set the JVM_VENDOR specific JVM flags
|
||||
if [ "${JVM_VENDOR}" = "SUN" ]; then
|
||||
DEFAULT_JAVA_OPTS="${DEFAULT_JAVA_OPTS} -Dcom.sun.management.jmxremote"
|
||||
elif [ "${JVM_VENDOR}" = "IBM" ]; then
|
||||
if ${os400}; then
|
||||
DEFAULT_JAVA_OPTS="${DEFAULT_JAVA_OPTS}"
|
||||
elif ${aix}; then
|
||||
DEFAULT_JAVA_OPTS="-Xverify:none -Xdump:heap -Xlp ${DEFAULT_JAVA_OPTS}"
|
||||
else
|
||||
DEFAULT_JAVA_OPTS="-Xverify:none ${DEFAULT_JAVA_OPTS}"
|
||||
fi
|
||||
fi
|
||||
|
||||
DEFAULT_JAVA_DEBUG_PORT="5005"
|
||||
if [ "x${JAVA_DEBUG_PORT}" = "x" ]; then
|
||||
JAVA_DEBUG_PORT="${DEFAULT_JAVA_DEBUG_PORT}"
|
||||
fi
|
||||
DEFAULT_JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${JAVA_DEBUG_PORT}"
|
||||
DEFAULT_JAVA_DEBUGS_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${JAVA_DEBUG_PORT}"
|
||||
|
||||
##
|
||||
## TODO: Move to conf/profiler/yourkit.{sh|cmd}
|
||||
##
|
||||
# Uncomment to enable YourKit profiling
|
||||
#DEFAULT_JAVA_DEBUG_OPTS="-Xrunyjpagent"
|
||||
}
|
||||
|
||||
convertPaths() {
|
||||
if $cygwin; then
|
||||
if [ ! -z "${KARAF_HOME}" ]; then
|
||||
KARAF_HOME=$(cygpath --path --windows "${KARAF_HOME}")
|
||||
fi
|
||||
if [ ! -z "${KARAF_BASE}" ]; then
|
||||
KARAF_BASE=$(cygpath --path --windows "${KARAF_BASE}")
|
||||
fi
|
||||
if [ ! -z "${KARAF_DATA}" ]; then
|
||||
KARAF_DATA=$(cygpath --path --windows "${KARAF_DATA}")
|
||||
fi
|
||||
if [ ! -z "${KARAF_ETC}" ]; then
|
||||
KARAF_ETC=$(cygpath --path --windows "${KARAF_ETC}")
|
||||
fi
|
||||
if [ ! -z "${CLASSPATH}" ]; then
|
||||
CLASSPATH=$(cygpath --path --windows "${CLASSPATH}")
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
143
runtime/bin/instance
Normal file
143
runtime/bin/instance
Normal file
@@ -0,0 +1,143 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
setupClassPath() {
|
||||
# Setup classpath
|
||||
CLASSPATH="${KARAF_HOME}/system/org/apache/karaf/instance/org.apache.karaf.instance.core/4.2.1/org.apache.karaf.instance.core-4.2.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/apache/karaf/shell/org.apache.karaf.shell.core/4.2.1/org.apache.karaf.shell.core-4.2.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/ops4j/pax/logging/pax-logging-api/1.10.1/pax-logging-api-1.10.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/jline/jline/3.9.0/jline-3.9.0.jar"
|
||||
}
|
||||
|
||||
init() {
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Unlimit the number of file descriptors if possible
|
||||
unlimitFD
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
|
||||
# Locate the Karaf base directory
|
||||
locateBase
|
||||
|
||||
# Locate the Karaf data directory
|
||||
locateData
|
||||
|
||||
# Locate the Karaf etc directory
|
||||
locateEtc
|
||||
|
||||
# Setup the native library path
|
||||
setupNativePath
|
||||
|
||||
# Locate the Java VM to execute
|
||||
locateJava
|
||||
|
||||
# Determine the JVM vendor
|
||||
detectJVM
|
||||
|
||||
# Setup default options
|
||||
setupDefaults
|
||||
|
||||
# Setup classpath
|
||||
setupClassPath
|
||||
|
||||
# Install debug options
|
||||
setupDebugOptions
|
||||
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
exec "${JAVA}" ${JAVA_OPTS} \
|
||||
-Dkaraf.instances="${KARAF_HOME}/instances" \
|
||||
-Dkaraf.home="${KARAF_HOME}" \
|
||||
-Dkaraf.base="${KARAF_BASE}" \
|
||||
-Dkaraf.etc="${KARAF_ETC}" \
|
||||
-Djava.io.tmpdir="${KARAF_DATA}/tmp" \
|
||||
-Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
|
||||
${KARAF_OPTS} ${OPTS} \
|
||||
-classpath "${CLASSPATH}" \
|
||||
org.apache.karaf.instance.main.Execute "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
158
runtime/bin/instance.bat
Normal file
158
runtime/bin/instance.bat
Normal file
@@ -0,0 +1,158 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="instance.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
|
||||
if "%JAVA_MIN_MEM%" == "" (
|
||||
set JAVA_MIN_MEM=128M
|
||||
)
|
||||
if "%JAVA_MAX_MEM%" == "" (
|
||||
set JAVA_MAX_MEM=512M
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
set DEFAULT_JAVA_OPTS=
|
||||
set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
|
||||
rem Support for loading native libraries
|
||||
set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
|
||||
|
||||
rem Setup the Java Virtual Machine
|
||||
if not "%JAVA%" == "" goto :Check_JAVA_END
|
||||
set JAVA=java
|
||||
if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
|
||||
if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
|
||||
if not exist "%JAVA_HOME%" (
|
||||
call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
|
||||
goto END
|
||||
)
|
||||
:Check_JAVA_END
|
||||
|
||||
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
|
||||
|
||||
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
|
||||
set JAVA_OPTS="%JAVA_OPTS% %EXTRA_JAVA_OPTS%"
|
||||
:KARAF_EXTRA_JAVA_OPTS_END
|
||||
|
||||
if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
|
||||
rem Use the defaults if JAVA_DEBUG_OPTS was not set
|
||||
if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
|
||||
|
||||
set JAVA_OPTS="%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
|
||||
call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
|
||||
:KARAF_DEBUG_END
|
||||
|
||||
rem Setup the classpath
|
||||
pushd "%KARAF_HOME%\lib"
|
||||
for %%G in (*.jar) do call:APPEND_TO_CLASSPATH %%G
|
||||
popd
|
||||
goto CLASSPATH_END
|
||||
|
||||
: APPEND_TO_CLASSPATH
|
||||
set filename=%~1
|
||||
set suffix=%filename:~-4%
|
||||
if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\%filename%
|
||||
goto :EOF
|
||||
|
||||
:CLASSPATH_END
|
||||
|
||||
set CLASSPATH=%KARAF_HOME%\system\org\apache\karaf\instance\org.apache.karaf.instance.core\4.2.1\org.apache.karaf.instance.core-4.2.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\apache\karaf\shell\org.apache.karaf.shell.core\4.2.1\org.apache.karaf.shell.core-4.2.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\ops4j\pax\logging\pax-logging-api\1.10.1\pax-logging-api-1.10.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\jline\jline\3.9.0\jline-3.9.0.jar
|
||||
|
||||
:EXECUTE
|
||||
if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
|
||||
if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
|
||||
rem Execute the Java Virtual Machine
|
||||
"%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.instances="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.etc="%KARAF_ETC%" -Djava.io.tmpdir="%KARAF_DATA%\tmp" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %KARAF_OPTS% org.apache.karaf.instance.main.Execute %ARGS%
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
362
runtime/bin/karaf
Normal file
362
runtime/bin/karaf
Normal file
@@ -0,0 +1,362 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
LOCAL_CLASSPATH=$CLASSPATH
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
forceNoRoot() {
|
||||
# If configured, prevent execution as root
|
||||
if [ "${KARAF_NOROOT}" ] && [ "$(id -u)" -eq 0 ]; then
|
||||
die "Do not run as root!"
|
||||
fi
|
||||
}
|
||||
|
||||
setupClassPath() {
|
||||
# Add the jars in the lib dir
|
||||
for file in "${KARAF_HOME}"/lib/boot/*.jar
|
||||
do
|
||||
if [ -z "${CLASSPATH}" ]; then
|
||||
CLASSPATH="${file}"
|
||||
else
|
||||
CLASSPATH="${CLASSPATH}:${file}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
checkRootInstance() {
|
||||
ROOT_INSTANCE_RUNNING=false
|
||||
if [ -f "${KARAF_DATA}/tmp/instances/instance.properties" ];
|
||||
then
|
||||
ROOT_INSTANCE_PID=$(sed -n -e '/item.0.pid/ s/.*\= *//p' "${KARAF_DATA}/tmp/instances/instance.properties")
|
||||
ROOT_INSTANCE_NAME=$(sed -n -e '/item.0.name/ s/.*\= *//p' "${KARAF_DATA}/tmp/instances/instance.properties")
|
||||
if [ "${ROOT_INSTANCE_PID}" -ne "0" ]; then
|
||||
if ps -p "${ROOT_INSTANCE_PID}" > /dev/null
|
||||
then
|
||||
MAIN=org.apache.karaf.main.Main
|
||||
PID_COMMAND=$("${PS_PREFIX}"ps -p "${ROOT_INSTANCE_PID}" -o args | sed 1d)
|
||||
|
||||
if [ "${PID_COMMAND#*$MAIN}" != "$PID_COMMAND" ]; then
|
||||
ROOT_INSTANCE_RUNNING=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
init() {
|
||||
# Prevent root execution if configured
|
||||
forceNoRoot
|
||||
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Unlimit the number of file descriptors if possible
|
||||
unlimitFD
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
|
||||
# Locate the Karaf base directory
|
||||
locateBase
|
||||
|
||||
# Locate the Karaf data directory
|
||||
locateData
|
||||
|
||||
# Locate the Karaf etc directory
|
||||
locateEtc
|
||||
|
||||
# Setup the native library path
|
||||
setupNativePath
|
||||
|
||||
# Locate the Java VM to execute
|
||||
locateJava
|
||||
|
||||
# Determine the JVM vendor
|
||||
detectJVM
|
||||
|
||||
# Determine the JVM version >= 1.6
|
||||
checkJvmVersion
|
||||
|
||||
# Check if a root instance is already running
|
||||
checkRootInstance
|
||||
|
||||
# Setup default options
|
||||
setupDefaults
|
||||
|
||||
# Setup classpath
|
||||
setupClassPath
|
||||
|
||||
# Install debug options
|
||||
setupDebugOptions
|
||||
|
||||
}
|
||||
|
||||
run() {
|
||||
OPTS="-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=true"
|
||||
MAIN=org.apache.karaf.main.Main
|
||||
if [ "x$CHECK_ROOT_INSTANCE_RUNNING" = "x" ]; then
|
||||
CHECK_ROOT_INSTANCE_RUNNING=true
|
||||
fi
|
||||
JAVA_ENDORSED_DIRS="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed"
|
||||
JAVA_EXT_DIRS="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext"
|
||||
if ${cygwin}; then
|
||||
JAVA_HOME=$(cygpath --path --windows "${JAVA_HOME}")
|
||||
JAVA_ENDORSED_DIRS=$(cygpath --path --windows "${JAVA_ENDORSED_DIRS}")
|
||||
JAVA_EXT_DIRS=$(cygpath --path --windows "${JAVA_EXT_DIRS}")
|
||||
fi
|
||||
convertPaths
|
||||
cd "${KARAF_BASE}" || exit 2
|
||||
|
||||
if [ -z "${KARAF_EXEC}" ]; then
|
||||
KARAF_EXEC=""
|
||||
fi
|
||||
|
||||
debug=false
|
||||
debugs=false
|
||||
nodebug=false
|
||||
while [ "${1}" != "" ]; do
|
||||
case "${1}" in
|
||||
'clean')
|
||||
rm -rf "${KARAF_DATA:?}"
|
||||
shift
|
||||
;;
|
||||
'debug')
|
||||
debug=true
|
||||
shift
|
||||
;;
|
||||
'debugs')
|
||||
debug=true
|
||||
debugs=true
|
||||
shift
|
||||
;;
|
||||
'status')
|
||||
MAIN=org.apache.karaf.main.Status
|
||||
CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
nodebug=true
|
||||
shift
|
||||
;;
|
||||
'stop')
|
||||
MAIN=org.apache.karaf.main.Stop
|
||||
CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
nodebug=true
|
||||
shift
|
||||
;;
|
||||
'console')
|
||||
CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
shift
|
||||
;;
|
||||
'server')
|
||||
OPTS="-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true"
|
||||
shift
|
||||
;;
|
||||
'run')
|
||||
OPTS="-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -Dkaraf.log.console=ALL"
|
||||
shift
|
||||
;;
|
||||
'daemon')
|
||||
OPTS="-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true"
|
||||
KARAF_DAEMON="true"
|
||||
KARAF_EXEC="exec"
|
||||
shift
|
||||
;;
|
||||
'client')
|
||||
OPTS="-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false"
|
||||
CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
nodebug=true
|
||||
shift
|
||||
;;
|
||||
'classpath')
|
||||
echo "Classpath: ${CLASSPATH}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ${nodebug}; then
|
||||
debug=false
|
||||
fi
|
||||
if ${debug}; then
|
||||
if [ "x${JAVA_DEBUG_OPTS}" = "x" ]; then
|
||||
if ${debugs}; then
|
||||
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUGS_OPTS}"
|
||||
else
|
||||
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUG_OPTS}"
|
||||
fi
|
||||
fi
|
||||
JAVA_OPTS="${JAVA_DEBUG_OPTS} ${JAVA_OPTS}"
|
||||
fi
|
||||
|
||||
while true; do
|
||||
# When users want to update the lib version of, they just need to create
|
||||
# a lib.next directory and on the new restart, it will replace the current lib directory.
|
||||
if [ -d "${KARAF_HOME:?}/lib.next" ] ; then
|
||||
echo "Updating libs..."
|
||||
rm -rf "${KARAF_HOME:?}/lib"
|
||||
mv -f "${KARAF_HOME:?}/lib.next" "${KARAF_HOME}/lib"
|
||||
|
||||
echo "Updating classpath..."
|
||||
CLASSPATH=$LOCAL_CLASSPATH
|
||||
setupClassPath
|
||||
fi
|
||||
|
||||
# Ensure the log directory exists
|
||||
# We may need to have a place to redirect stdout/stderr
|
||||
if [ ! -d "${OPENHAB_LOGDIR}" ]; then
|
||||
mkdir -p "${OPENHAB_LOGDIR}"
|
||||
fi
|
||||
if [ ! -d "${KARAF_DATA}/tmp" ]; then
|
||||
mkdir -p "${KARAF_DATA}/tmp"
|
||||
fi
|
||||
|
||||
if [ "${ROOT_INSTANCE_RUNNING}" = "false" ] || [ "${CHECK_ROOT_INSTANCE_RUNNING}" = "false" ] ; then
|
||||
if [ "${VERSION}" -gt "8" ]; then
|
||||
${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
|
||||
--add-reads=java.xml=java.logging \
|
||||
--patch-module java.base=lib/endorsed/org.apache.karaf.specs.locator-4.2.1.jar \
|
||||
--patch-module java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-4.2.1.jar \
|
||||
--add-opens java.base/java.security=ALL-UNNAMED \
|
||||
--add-opens java.base/java.net=ALL-UNNAMED \
|
||||
--add-opens java.base/java.lang=ALL-UNNAMED \
|
||||
--add-opens java.base/java.util=ALL-UNNAMED \
|
||||
--add-opens java.naming/javax.naming.spi=ALL-UNNAMED \
|
||||
--add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED \
|
||||
--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED \
|
||||
--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED \
|
||||
--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED \
|
||||
--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED \
|
||||
--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED \
|
||||
-Dkaraf.instances="${KARAF_DATA}/tmp/instances" \
|
||||
-Dkaraf.home="${KARAF_HOME}" \
|
||||
-Dkaraf.base="${KARAF_BASE}" \
|
||||
-Dkaraf.data="${KARAF_DATA}" \
|
||||
-Dkaraf.etc="${KARAF_ETC}" \
|
||||
-Dkaraf.logs="${OPENHAB_LOGDIR}" \
|
||||
-Dkaraf.restart.jvm.supported=true \
|
||||
-Djava.io.tmpdir="${KARAF_DATA}/tmp" \
|
||||
-Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
|
||||
${KARAF_SYSTEM_OPTS} \
|
||||
${KARAF_OPTS} \
|
||||
${OPTS} \
|
||||
-classpath "${CLASSPATH}" \
|
||||
${MAIN} "$@"
|
||||
else
|
||||
${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
|
||||
-Djava.endorsed.dirs="${JAVA_ENDORSED_DIRS}" \
|
||||
-Djava.ext.dirs="${JAVA_EXT_DIRS}" \
|
||||
-Dkaraf.instances="${KARAF_DATA}/tmp/instances" \
|
||||
-Dkaraf.home="${KARAF_HOME}" \
|
||||
-Dkaraf.base="${KARAF_BASE}" \
|
||||
-Dkaraf.data="${KARAF_DATA}" \
|
||||
-Dkaraf.etc="${KARAF_ETC}" \
|
||||
-Dkaraf.logs="${OPENHAB_LOGDIR}" \
|
||||
-Dkaraf.restart.jvm.supported=true \
|
||||
-Djava.io.tmpdir="${KARAF_DATA}/tmp" \
|
||||
-Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
|
||||
${KARAF_SYSTEM_OPTS} \
|
||||
${KARAF_OPTS} \
|
||||
${OPTS} \
|
||||
-classpath "${CLASSPATH}" \
|
||||
${MAIN} "$@"
|
||||
fi
|
||||
else
|
||||
die "There is a Root instance already running with name ${ROOT_INSTANCE_NAME} and pid ${ROOT_INSTANCE_PID}. If you know what you are doing and want to force the run anyway, export CHECK_ROOT_INSTANCE_RUNNING=false and re run the command."
|
||||
fi
|
||||
|
||||
KARAF_RC=$?
|
||||
if [ ${KARAF_DAEMON} ] ; then
|
||||
exit ${KARAF_RC}
|
||||
else
|
||||
if [ "${KARAF_RC}" -eq 10 ]; then
|
||||
echo "Restarting JVM..."
|
||||
else
|
||||
exit ${KARAF_RC}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
nothing() {
|
||||
# nothing to do here
|
||||
a=a
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
trap 'nothing' TSTP
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
484
runtime/bin/karaf.bat
Normal file
484
runtime/bin/karaf.bat
Normal file
@@ -0,0 +1,484 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="karaf.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
|
||||
if "%JAVA_MIN_MEM%" == "" (
|
||||
set JAVA_MIN_MEM=128M
|
||||
)
|
||||
if "%JAVA_MAX_MEM%" == "" (
|
||||
set JAVA_MAX_MEM=512M
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
call :warn Creating "%KARAF_DATA%"
|
||||
mkdir "%KARAF_DATA%"
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
set LOCAL_CLASSPATH=%CLASSPATH%
|
||||
set JAVA_MODE=-server
|
||||
|
||||
set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
|
||||
set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
set DEFAULT_JAVA_DEBUGS_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
|
||||
|
||||
if "%LOCAL_CLASSPATH%" == "" goto :KARAF_CLASSPATH_EMPTY
|
||||
set CLASSPATH=%LOCAL_CLASSPATH%;%KARAF_BASE%\conf
|
||||
goto :KARAF_CLASSPATH_END
|
||||
:KARAF_CLASSPATH_EMPTY
|
||||
set CLASSPATH=%KARAF_BASE%\conf
|
||||
:KARAF_CLASSPATH_END
|
||||
|
||||
set CLASSPATH_INITIAL=%CLASSPATH%
|
||||
|
||||
rem Setup Karaf Home
|
||||
if exist "%KARAF_HOME%\conf\karaf-rc.cmd" call %KARAF_HOME%\conf\karaf-rc.cmd
|
||||
if exist "%HOME%\karaf-rc.cmd" call %HOME%\karaf-rc.cmd
|
||||
|
||||
rem Support for loading native libraries
|
||||
set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
|
||||
|
||||
rem Setup the Java Virtual Machine
|
||||
if not "%JAVA%" == "" goto :Check_JAVA_END
|
||||
if not "%JAVA_HOME%" == "" goto :TryJDKEnd
|
||||
call :warn JAVA_HOME not set; results may vary
|
||||
:TryJRE
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
|
||||
if not exist __reg1.txt goto :TryJDK
|
||||
type __reg1.txt | find "CurrentVersion" > __reg2.txt
|
||||
if errorlevel 1 goto :TryJDK
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
|
||||
if errorlevel 1 goto :TryJDK
|
||||
set JavaTemp=%JavaTemp%##
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp:##=%
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\%JavaTemp%"
|
||||
if not exist __reg1.txt goto :TryJDK
|
||||
type __reg1.txt | find "JavaHome" > __reg2.txt
|
||||
if errorlevel 1 goto :TryJDK
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
|
||||
if errorlevel 1 goto :TryJDK
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
goto TryJDKEnd
|
||||
:TryJDK
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
|
||||
if not exist __reg1.txt (
|
||||
goto TryRegJRE
|
||||
)
|
||||
type __reg1.txt | find "CurrentVersion" > __reg2.txt
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
set JavaTemp=%JavaTemp%##
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp:##=%
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\%JavaTemp%"
|
||||
if not exist __reg1.txt (
|
||||
goto TryRegJRE
|
||||
)
|
||||
type __reg1.txt | find "JavaHome" > __reg2.txt
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
:TryRegJRE
|
||||
rem try getting the JAVA_HOME from registry
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion`) DO (
|
||||
set JAVA_VERSION=%%A
|
||||
)
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\%JAVA_VERSION%" /v JavaHome`) DO (
|
||||
set JAVA_HOME=%%A %%B
|
||||
)
|
||||
if not exist "%JAVA_HOME%" (
|
||||
goto TryRegJDK
|
||||
)
|
||||
goto TryJDKEnd
|
||||
:TryRegJDK
|
||||
rem try getting the JAVA_HOME from registry
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Development Kit" /v CurrentVersion`) DO (
|
||||
set JAVA_VERSION=%%A
|
||||
)
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Development Kit\%JAVA_VERSION%" /v JavaHome`) DO (
|
||||
set JAVA_HOME=%%A %%B
|
||||
)
|
||||
if not exist "%JAVA_HOME%" (
|
||||
call :warn Unable to retrieve JAVA_HOME from Registry
|
||||
)
|
||||
goto TryJDKEnd
|
||||
:TryJDKEnd
|
||||
if not exist "%JAVA_HOME%" (
|
||||
call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
|
||||
goto END
|
||||
)
|
||||
set JAVA=%JAVA_HOME%\bin\java
|
||||
:Check_JAVA_END
|
||||
|
||||
rem Retrieve java version
|
||||
for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do (
|
||||
if %%j==1 (set JAVA_VERSION=%%k) else (set JAVA_VERSION=%%j)
|
||||
)
|
||||
|
||||
:CheckRootInstance
|
||||
set ROOT_INSTANCE_RUNNING=false
|
||||
if exist "%OPENHAB_USERDATA%\tmp\instances\instance.properties" (
|
||||
for /f "delims=" %%x in ( 'findstr "item.0.pid" "%OPENHAB_USERDATA%\tmp\instances\instance.properties" ' ) do @set pid=%%x
|
||||
for /f "delims=" %%i in ( 'findstr "item.0.name" "%OPENHAB_USERDATA%\tmp\instances\instance.properties" ' ) do @set name=%%i
|
||||
)
|
||||
set ROOT_INSTANCE_PID=%pid:~13%
|
||||
|
||||
set ROOT_INSTANCE_NAME=%name:~14%
|
||||
SET CHECK_RUNNING_CONDITION=true
|
||||
if "%ROOT_INSTANCE_PID%" == "~13" SET CHECK_RUNNING_CONDITION=false
|
||||
if "%ROOT_INSTANCE_PID%" == "0" SET CHECK_RUNNING_CONDITION=false
|
||||
if "%CHECK_RUNNING_CONDITION%" == "true" (
|
||||
tasklist /FI "PID eq %ROOT_INSTANCE_PID%" 2>NUL | find /I /N "java.exe" > NUL
|
||||
if not errorlevel 1 set ROOT_INSTANCE_RUNNING=true
|
||||
)
|
||||
|
||||
|
||||
if not exist "%JAVA_HOME%\bin\server\jvm.dll" (
|
||||
if not exist "%JAVA_HOME%\jre\bin\server\jvm.dll" (
|
||||
echo WARNING: Running Karaf on a Java HotSpot Client VM because server-mode is not available.
|
||||
echo Install Java Developer Kit to fix this.
|
||||
echo For more details see http://java.sun.com/products/hotspot/whitepaper.html#client
|
||||
set JAVA_MODE=-client
|
||||
)
|
||||
)
|
||||
set DEFAULT_JAVA_OPTS=%JAVA_MODE% -Xms%JAVA_MIN_MEM% -Xmx%JAVA_MAX_MEM% -Dcom.sun.management.jmxremote -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass
|
||||
|
||||
rem Check some easily accessible MIN/MAX params for JVM mem usage
|
||||
if not "%JAVA_PERM_MEM%" == "" (
|
||||
set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:PermSize=%JAVA_PERM_MEM%
|
||||
)
|
||||
if not "%JAVA_MAX_PERM_MEM%" == "" (
|
||||
set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -XX:MaxPermSize=%JAVA_MAX_PERM_MEM%
|
||||
)
|
||||
|
||||
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
|
||||
|
||||
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
|
||||
set JAVA_OPTS=%JAVA_OPTS% %EXTRA_JAVA_OPTS%
|
||||
:KARAF_EXTRA_JAVA_OPTS_END
|
||||
|
||||
if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
|
||||
if "%1" == "stop" goto :KARAF_DEBUG_END
|
||||
if "%1" == "client" goto :KARAF_DEBUG_END
|
||||
if "%1" == "status" goto :KARAF_DEBUG_END
|
||||
rem Use the defaults if JAVA_DEBUG_OPTS was not set
|
||||
if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
|
||||
|
||||
set JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%
|
||||
call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
|
||||
:KARAF_DEBUG_END
|
||||
|
||||
if "%KARAF_PROFILER%" == "" goto :KARAF_PROFILER_END
|
||||
set KARAF_PROFILER_SCRIPT=%KARAF_HOME%\conf\profiler\%KARAF_PROFILER%.cmd
|
||||
|
||||
if exist "%KARAF_PROFILER_SCRIPT%" goto :KARAF_PROFILER_END
|
||||
call :warn Missing configuration for profiler '%KARAF_PROFILER%': %KARAF_PROFILER_SCRIPT%
|
||||
goto END
|
||||
:KARAF_PROFILER_END
|
||||
|
||||
rem Setup the classpath
|
||||
pushd "%KARAF_HOME%\lib\boot"
|
||||
for %%G in (*.jar) do call:APPEND_TO_CLASSPATH %%G
|
||||
popd
|
||||
goto CLASSPATH_END
|
||||
|
||||
: APPEND_TO_CLASSPATH
|
||||
set filename=%~1
|
||||
set suffix=%filename:~-4%
|
||||
if %suffix% equ .jar set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\lib\boot\%filename%
|
||||
goto :EOF
|
||||
|
||||
:CLASSPATH_END
|
||||
|
||||
if "%CHECK_ROOT_INSTANCE_RUNNING%" == "" (
|
||||
SET CHECK_ROOT_INSTANCE_RUNNING=true
|
||||
)
|
||||
|
||||
rem Execute the JVM or the load the profiler
|
||||
if "%KARAF_PROFILER%" == "" goto :RUN
|
||||
rem Execute the profiler if it has been configured
|
||||
call :warn Loading profiler script: %KARAF_PROFILER_SCRIPT%
|
||||
call %KARAF_PROFILER_SCRIPT%
|
||||
|
||||
:RUN
|
||||
SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=true
|
||||
SET MAIN=org.apache.karaf.main.Main
|
||||
SET SHIFT=false
|
||||
|
||||
:RUN_LOOP
|
||||
if "%1" == "stop" goto :EXECUTE_STOP
|
||||
if "%1" == "status" goto :EXECUTE_STATUS
|
||||
if "%1" == "console" goto :EXECUTE_CONSOLE
|
||||
if "%1" == "server" goto :EXECUTE_SERVER
|
||||
if "%1" == "run" goto :EXECUTE_RUN
|
||||
if "%1" == "daemon" goto :EXECUTE_DAEMON
|
||||
if "%1" == "client" goto :EXECUTE_CLIENT
|
||||
if "%1" == "clean" goto :EXECUTE_CLEAN
|
||||
if "%1" == "debug" goto :EXECUTE_DEBUG
|
||||
if "%1" == "debugs" goto :EXECUTE_DEBUGS
|
||||
goto :EXECUTE
|
||||
|
||||
:EXECUTE_STOP
|
||||
SET MAIN=org.apache.karaf.main.Stop
|
||||
SET CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_STATUS
|
||||
SET MAIN=org.apache.karaf.main.Status
|
||||
SET CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_CONSOLE
|
||||
SET CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_SERVER
|
||||
SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_RUN
|
||||
SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -Dkaraf.log.console=ALL
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_DAEMON
|
||||
SET OPTS=-Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true
|
||||
SET KARAF_DAEMON=true
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_CLIENT
|
||||
SET OPTS=-Dkaraf.startLocalConsole=true -Dkaraf.startRemoteShell=false
|
||||
SET CHECK_ROOT_INSTANCE_RUNNING=false
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_CLEAN
|
||||
pushd "%KARAF_DATA%" && (rmdir /S /Q "%KARAF_DATA%" 2>nul & popd)
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_DEBUG
|
||||
if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
|
||||
set JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE_DEBUGS
|
||||
if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUGS_OPTS%
|
||||
set JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%
|
||||
shift
|
||||
goto :RUN_LOOP
|
||||
|
||||
:EXECUTE
|
||||
SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
|
||||
rem Execute the Java Virtual Machine
|
||||
cd "%KARAF_BASE%"
|
||||
|
||||
rem When users want to update the lib version of, they just need to create
|
||||
rem a lib.next directory and on the new restart, it will replace the current lib directory.
|
||||
if exist "%KARAF_HOME%\lib.next" (
|
||||
echo Updating libs...
|
||||
RD /S /Q "%KARAF_HOME%\lib"
|
||||
MOVE /Y "%KARAF_HOME%\lib.next" "%KARAF_HOME%\lib"
|
||||
|
||||
echo "Updating classpath..."
|
||||
set CLASSPATH=%CLASSPATH_INITIAL%
|
||||
pushd "%KARAF_HOME%\lib\boot"
|
||||
for %%G in (*.jar) do call:APPEND_TO_CLASSPATH %%G
|
||||
popd
|
||||
)
|
||||
|
||||
SET IS_RUNNABLE=false
|
||||
if "%ROOT_INSTANCE_RUNNING%" == "false" SET IS_RUNNABLE=true
|
||||
if "%CHECK_ROOT_INSTANCE_RUNNING%" == "false" SET IS_RUNNABLE=true
|
||||
if "%IS_RUNNABLE%" == "true" (
|
||||
rem If major version is greater than 1 (meaning Java 9 or 10), we don't use endorsed lib but module
|
||||
rem If major version is 1 (meaning Java 1.6, 1.7, 1.8), we use endorsed lib
|
||||
if %JAVA_VERSION% GTR 8 (
|
||||
"%JAVA%" %JAVA_OPTS% %OPTS% ^
|
||||
--add-reads=java.xml=java.logging ^
|
||||
--patch-module java.base=lib/endorsed/org.apache.karaf.specs.locator-4.2.1.jar ^
|
||||
--patch-module java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-4.2.1.jar ^
|
||||
--add-opens java.base/java.security=ALL-UNNAMED ^
|
||||
--add-opens java.base/java.net=ALL-UNNAMED ^
|
||||
--add-opens java.base/java.lang=ALL-UNNAMED ^
|
||||
--add-opens java.base/java.util=ALL-UNNAMED ^
|
||||
--add-opens java.naming/javax.naming.spi=ALL-UNNAMED ^
|
||||
--add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED ^
|
||||
--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED ^
|
||||
--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED ^
|
||||
--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED ^
|
||||
--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED ^
|
||||
--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED ^
|
||||
-classpath "%CLASSPATH%" ^
|
||||
-Dkaraf.instances="%OPENHAB_USERDATA%\tmp\instances" ^
|
||||
-Dkaraf.home="%KARAF_HOME%" ^
|
||||
-Dkaraf.base="%KARAF_BASE%" ^
|
||||
-Dkaraf.etc="%KARAF_ETC%" ^
|
||||
-Dkaraf.logs="%OPENHAB_LOGDIR%" ^
|
||||
-Dkaraf.restart.jvm.supported=true ^
|
||||
-Djava.io.tmpdir="%KARAF_DATA%\tmp" ^
|
||||
-Dkaraf.data="%KARAF_DATA%" ^
|
||||
-Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" ^
|
||||
%KARAF_SYSTEM_OPTS% %KARAF_OPTS% %MAIN% %ARGS%
|
||||
) else (
|
||||
"%JAVA%" %JAVA_OPTS% %OPTS% ^
|
||||
-classpath "%CLASSPATH%" ^
|
||||
-Djava.endorsed.dirs="%JAVA_HOME%\jre\lib\endorsed;%JAVA_HOME%\lib\endorsed;%KARAF_HOME%\lib\endorsed" ^
|
||||
-Djava.ext.dirs="%JAVA_HOME%\jre\lib\ext;%JAVA_HOME%\lib\ext;%KARAF_HOME%\lib\ext" ^
|
||||
-Dkaraf.instances="%OPENHAB_USERDATA%\tmp\instances" ^
|
||||
-Dkaraf.home="%KARAF_HOME%" ^
|
||||
-Dkaraf.base="%KARAF_BASE%" ^
|
||||
-Dkaraf.etc="%KARAF_ETC%" ^
|
||||
-Dkaraf.logs="%OPENHAB_LOGDIR%" ^
|
||||
-Dkaraf.restart.jvm.supported=true ^
|
||||
-Djava.io.tmpdir="%KARAF_DATA%\tmp" ^
|
||||
-Dkaraf.data="%KARAF_DATA%" ^
|
||||
-Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" ^
|
||||
%KARAF_SYSTEM_OPTS% %KARAF_OPTS% %MAIN% %ARGS%
|
||||
)
|
||||
) else (
|
||||
echo There is a Root instance already running with name %ROOT_INSTANCE_NAME% and pid %ROOT_INSTANCE_PID%. If you know what you are doing and want to force the run anyway, SET CHECK_ROOT_INSTANCE_RUNNING=false and re run the command.
|
||||
goto :END
|
||||
)
|
||||
|
||||
rem If KARAF_DAEMON is defined, auto-restart is bypassed and control given
|
||||
rem back to the operating system
|
||||
if defined "%KARAF_DAEMON%" (
|
||||
rem If Karaf has been started by winsw, the process can be restarted
|
||||
rem by executing KARAF_DAEMON% restart!
|
||||
rem https://github.com/kohsuke/winsw#restarting-service-from-itself
|
||||
if defined "%WINSW_EXECUTABLE%" (
|
||||
if ERRORLEVEL 10 (
|
||||
echo Restarting ...
|
||||
%KARAF_DAEMON% restart!
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if ERRORLEVEL 10 (
|
||||
echo Restarting JVM...
|
||||
goto EXECUTE
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
if not "%PAUSE%" == "" pause
|
||||
|
||||
:END_NO_PAUSE
|
||||
EXIT /B %ERRORLEVEL%
|
||||
37
runtime/bin/oh2_dir_layout
Normal file
37
runtime/bin/oh2_dir_layout
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# DIRNAME is the directory of karaf, setenv, etc.
|
||||
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
|
||||
|
||||
export OPENHAB_HOME=`cd "$DIRNAME/../.."; pwd`
|
||||
|
||||
if [ -z ${OPENHAB_CONF} ]; then
|
||||
export OPENHAB_CONF="${OPENHAB_HOME}/conf"
|
||||
fi
|
||||
|
||||
if [ -z ${OPENHAB_RUNTIME} ]; then
|
||||
export OPENHAB_RUNTIME="${OPENHAB_HOME}/runtime"
|
||||
fi
|
||||
|
||||
if [ -z ${OPENHAB_USERDATA} ]; then
|
||||
export OPENHAB_USERDATA="${OPENHAB_HOME}/userdata"
|
||||
fi
|
||||
|
||||
if [ -z ${OPENHAB_LOGDIR} ]; then
|
||||
export OPENHAB_LOGDIR="${OPENHAB_USERDATA}/logs"
|
||||
fi
|
||||
|
||||
if [ -z ${OPENHAB_BACKUPS} ]; then
|
||||
export OPENHAB_BACKUPS="${OPENHAB_HOME}/backups"
|
||||
fi
|
||||
|
||||
|
||||
# Make sure the tmp folder exists as Karaf requires it
|
||||
if [ ! -d "${OPENHAB_USERDATA}/tmp" ]; then
|
||||
mkdir "${OPENHAB_USERDATA}/tmp"
|
||||
fi
|
||||
|
||||
|
||||
export KARAF_DATA="${OPENHAB_USERDATA}"
|
||||
export KARAF_BASE="${OPENHAB_USERDATA}"
|
||||
export KARAF_ETC="${OPENHAB_USERDATA}/etc"
|
||||
44
runtime/bin/oh2_dir_layout.bat
Normal file
44
runtime/bin/oh2_dir_layout.bat
Normal file
@@ -0,0 +1,44 @@
|
||||
rem DIRNAME is the directory of karaf, setenv, etc.
|
||||
CALL :removeSpacesFromPath "%DIRNAME%..\.."
|
||||
|
||||
set OPENHAB_HOME=%RETVAL%
|
||||
|
||||
:check_conf
|
||||
IF NOT [%OPENHAB_CONF%] == [] GOTO :conf_set
|
||||
set OPENHAB_CONF=%OPENHAB_HOME%\conf
|
||||
:conf_set
|
||||
|
||||
:check_runtime
|
||||
IF NOT [%OPENHAB_RUNTIME%] == [] GOTO :runtime_set
|
||||
set OPENHAB_RUNTIME=%OPENHAB_HOME%\runtime
|
||||
:runtime_set
|
||||
|
||||
:check_userdata
|
||||
IF NOT [%OPENHAB_USERDATA%] == [] GOTO :userdata_set
|
||||
set OPENHAB_USERDATA=%OPENHAB_HOME%\userdata
|
||||
:userdata_set
|
||||
|
||||
:check_logs
|
||||
IF NOT [%OPENHAB_LOGDIR%] == [] GOTO :logs_set
|
||||
set OPENHAB_LOGDIR=%OPENHAB_USERDATA%\logs
|
||||
:logs_set
|
||||
|
||||
:check_backups
|
||||
IF NOT [%OPENHAB_BACKUPS%] == [] GOTO :backups_set
|
||||
set OPENHAB_BACKUPS=%OPENHAB_HOME%\backups
|
||||
:backups_set
|
||||
|
||||
rem Make sure the tmp folder exists as Karaf requires it
|
||||
IF NOT EXIST "%OPENHAB_USERDATA%\tmp" (
|
||||
mkdir "%OPENHAB_USERDATA%\tmp"
|
||||
)
|
||||
|
||||
set KARAF_DATA=%OPENHAB_USERDATA%
|
||||
set KARAF_BASE=%OPENHAB_USERDATA%
|
||||
set KARAF_ETC=%OPENHAB_USERDATA%\etc
|
||||
|
||||
EXIT /B
|
||||
|
||||
:removeSpacesFromPath
|
||||
SET RETVAL=%~s1
|
||||
EXIT /B
|
||||
190
runtime/bin/restore
Normal file
190
runtime/bin/restore
Normal file
@@ -0,0 +1,190 @@
|
||||
#!/bin/sh
|
||||
|
||||
setup(){
|
||||
if [ -z "$1" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||
echo "Usage: restore filename"
|
||||
echo ""
|
||||
echo " e.g. ./restore myBackup.zip << Restores config from myBackup.zip"
|
||||
echo ""
|
||||
echo "Use this script to restore an openHAB configuration that was previously made with"
|
||||
echo "the openHAB 'backup' script."
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
## Ask to run as root to prevent us from running sudo in this script.
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run this script as root! (e.g. use sudo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v unzip >/dev/null 2>&1 || {
|
||||
echo "'unzip' program was not found, please install it first." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Check to see if processes are running before restoring
|
||||
if [ ! -z "$(pgrep -f "openhab2.*java")" ]; then
|
||||
echo "openHAB is running! Please stop the process before restoring." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WorkingDir="$(cd "$(dirname "$0")" && cd ../.. && pwd -P)"
|
||||
|
||||
## Set path variables
|
||||
if [ -r /etc/profile.d/openhab2.sh ]; then
|
||||
. /etc/profile.d/openhab2.sh
|
||||
elif [ -r /etc/default/openhab2 ]; then
|
||||
. /etc/default/openhab2
|
||||
fi
|
||||
if [ -z "$OPENHAB_CONF" ]; then OPENHAB_CONF="$WorkingDir/conf"; fi
|
||||
if [ -z "$OPENHAB_USERDATA" ]; then OPENHAB_USERDATA="$WorkingDir/userdata"; fi
|
||||
|
||||
echo "Using '$OPENHAB_CONF' as conf folder..."
|
||||
echo "Using '$OPENHAB_USERDATA' as userdata folder..."
|
||||
|
||||
## Check two of the standard openHAB folders to make sure we're updating the right thing.
|
||||
if [ ! -d "$OPENHAB_USERDATA" ] || [ ! -d "$OPENHAB_CONF" ]; then
|
||||
echo "Configuration paths are invalid..." >&2
|
||||
echo "Try setting OPENHAB_USERDATA and OPENHAB_CONF environment variables." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
currentUser=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $3}')
|
||||
currentGroup=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $4}')
|
||||
|
||||
CurrentVersion="$(awk '/openhab-distro/{print $3}' "$OPENHAB_USERDATA/etc/version.properties")"
|
||||
|
||||
## Store anything in temporary folders
|
||||
TempDir="/tmp/openhab2/restore"
|
||||
## Clear older stuff if it exists
|
||||
rm -rf "${TempDir:?}"
|
||||
echo "Making Temporary Directory"
|
||||
mkdir -p "$TempDir" || {
|
||||
echo "Failed to make temporary directory: $TempDir" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
echo " "
|
||||
echo "##########################################"
|
||||
echo " openHAB 2.x.x restore script "
|
||||
echo "##########################################"
|
||||
echo " "
|
||||
|
||||
InputFile="$1"
|
||||
|
||||
setup "$InputFile"
|
||||
|
||||
## Extract zip file
|
||||
echo "Extracting zip file to temporary folder."
|
||||
|
||||
unzip -oq "$InputFile" -d "$TempDir" || {
|
||||
echo "Unable to unzip $InputFile, Aborting..." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Check for backup properties list.
|
||||
if [ ! -f "$TempDir/backup.properties" ]; then
|
||||
echo "Backup was not created by openHAB scripts, please resort to a manual restore..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Grab information with backup.properties
|
||||
str="$(awk '/version=/{print $1}' "$TempDir/backup.properties")"
|
||||
BackupVersion=${str#*=}
|
||||
str="$(awk '/timestamp=/{print $1}' "$TempDir/backup.properties")"
|
||||
BackupTime=${str#*=}
|
||||
str="$(awk '/user=/{print $1}' "$TempDir/backup.properties")"
|
||||
OHUser=${str#*=}
|
||||
str="$(awk '/group=/{print $1}' "$TempDir/backup.properties")"
|
||||
OHGroup=${str#*=}
|
||||
|
||||
## Feeback to user
|
||||
echo ""
|
||||
echo " Backup Information:"
|
||||
echo " -------------------"
|
||||
echo " Backup Version | $BackupVersion (You are on $CurrentVersion)"
|
||||
echo " Backup Timestamp | $BackupTime"
|
||||
echo " Config belongs to user | $OHUser"
|
||||
echo " from group | $OHGroup"
|
||||
echo ""
|
||||
echo "Your current configuration will become owned by $currentUser:$currentGroup."
|
||||
echo ""
|
||||
echo "Any existing files with the same name will be replaced."
|
||||
echo "Any file without a replacement will be deleted."
|
||||
echo ""
|
||||
printf "Okay to Continue? [y/N]: "
|
||||
read -r answer
|
||||
case "$answer" in
|
||||
[Yy]*)
|
||||
;;
|
||||
*)
|
||||
echo "Cancelling restore..."
|
||||
rm -rf /tmp/openhab2
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
## Move old configuration
|
||||
rm -rf /tmp/openhab/old
|
||||
mkdir -p /tmp/openhab/old
|
||||
echo "Moving system files in userdata to temporary folder"
|
||||
if [ -d "$OPENHAB_USERDATA/backups" ]; then
|
||||
mv "$OPENHAB_USERDATA/backups" /tmp/openhab/old || {
|
||||
echo "Could not move backup folder to temporary folder..." >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
if [ -d "${OPENHAB_USERDATA:?}/etc" ]; then
|
||||
mv "${OPENHAB_USERDATA:?}/etc" /tmp/openhab/old || {
|
||||
echo "Could not move etc folder to temporary folder" >&2
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Deleting old userdata folder..."
|
||||
rm -rf "${OPENHAB_USERDATA:?}/"*
|
||||
|
||||
echo "Restoring system files in userdata..."
|
||||
if [ -d /tmp/openhab/old/backups ]; then
|
||||
mv /tmp/openhab/old/backups "${OPENHAB_USERDATA:?}/" || {
|
||||
echo "Unable to move other backup files back..."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
if [ -d /tmp/openhab/old/etc ]; then
|
||||
mv /tmp/openhab/old/etc "${OPENHAB_USERDATA:?}/" || {
|
||||
echo "Unable to move system files back..."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Deleting old conf folder..."
|
||||
rm -rf "${OPENHAB_CONF:?}/"*
|
||||
|
||||
## Restore configuration
|
||||
echo "Restoring openHAB with backup configuration..."
|
||||
command cp -af "$TempDir/conf/"* "${OPENHAB_CONF:?}/" || {
|
||||
echo "Failed to copy $TempDir/conf/ to $OPENHAB_CONF/..." >&2
|
||||
echo "Please check $TempDir and replace conf and userdata." >&2
|
||||
exit 1
|
||||
}
|
||||
command cp -af "$TempDir/userdata/"* "${OPENHAB_USERDATA:?}/" || {
|
||||
echo "Failed to copy $TempDir/userdata/ to $OPENHAB_USERDATA/..." >&2
|
||||
echo "Please check $TempDir and replace userdata." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Reset ownership
|
||||
chown -R "$currentUser:$currentGroup" "$OPENHAB_USERDATA" || {
|
||||
echo "WARNING: Failed to change userdata folder permissions to $currentUser:$currentGroup" >&2
|
||||
}
|
||||
chown -R "$currentUser:$currentGroup" "$OPENHAB_CONF" || {
|
||||
echo "WARNING: Failed to change conf folder permissions to $currentUser:$currentGroup" >&2
|
||||
}
|
||||
|
||||
echo "Deleting temporary files..."
|
||||
rm -rf /tmp/openhab2
|
||||
echo "Backup successfully restored!"
|
||||
echo ""
|
||||
44
runtime/bin/restore.bat
Normal file
44
runtime/bin/restore.bat
Normal file
@@ -0,0 +1,44 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
|
||||
IF "%1"=="?" GOTO printArgs
|
||||
IF "%1"=="\?" GOTO printArgs
|
||||
IF "%1"=="/?" GOTO printArgs
|
||||
|
||||
|
||||
IF NOT [%~4]==[] IF NOT "%~4"=="true" IF NOT "%~4"=="false" GOTO printArgs
|
||||
|
||||
SET autoConfirm=False
|
||||
IF "%~4"=="true" SET autoConfirm=True
|
||||
|
||||
SET rargs=
|
||||
|
||||
IF NOT [%1]==[] ( SET rargs=%rargs% -OHDirectory %~1% )
|
||||
IF NOT [%2]==[] ( SET rargs=%rargs% -OHBackups %~2% )
|
||||
IF NOT [%3]==[] ( SET rargs=%rargs% -FileName %~3% )
|
||||
|
||||
CD %~dp0
|
||||
powershell -ExecutionPolicy Bypass -command "& { . .\restore.ps1; Restore-openHAB %rargs% -AutoConfirm $%autoConfirm% }"
|
||||
SET LEVEL=%ERRORLEVEL%
|
||||
|
||||
if %LEVEL% LSS 0 (
|
||||
PAUSE
|
||||
EXIT /B %LEVEL%
|
||||
)
|
||||
|
||||
EXIT /B 0
|
||||
|
||||
:printArgs
|
||||
ECHO Usage: restore.bat {OHDirectory} {OHBackups} {FileName} {AutoConfirm}
|
||||
ECHO OHDirectory (optional) - The openHAB distribution directory
|
||||
ECHO OHBackups (optional) - The directory where backups are stored
|
||||
ECHO FileName (optional) - The backup file name (found in OHBackups)
|
||||
ECHO AutoConfrim (optional) - "true" to automatically confirm restoration, "false" otherwise
|
||||
ECHO.
|
||||
ECHO Example to restore openHAB from the latest backup in the default locations
|
||||
ECHO restore.bat
|
||||
ECHO.
|
||||
ECHO Example to restore openHAB from the "backup.zip" found in "c:\openhab2\backups" with auto confirming:
|
||||
ECHO restore.bat "c:\openhab2" "c:\openhab2\backups" "backup.zip" true
|
||||
ECHO.
|
||||
EXIT /B -1
|
||||
244
runtime/bin/restore.ps1
Normal file
244
runtime/bin/restore.ps1
Normal file
@@ -0,0 +1,244 @@
|
||||
#Requires -Version 5.0
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
Function Restore-openHAB {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Restores openHAB files from a backup file.
|
||||
.DESCRIPTION
|
||||
The Restore-openHAB function performs the necessary tasks to restore openHAB from a backup file.
|
||||
.PARAMETER OHDirectory
|
||||
The directory where openHAB is installed (default: current directory).
|
||||
.PARAMETER OHBackups
|
||||
The directory where backup the files are.
|
||||
.PARAMETER FileName
|
||||
The name of the backup file to use (do not specify to use the latest)
|
||||
.PARAMETER AutoConfirm
|
||||
Whether to auto confirm ($true) replacement of files (used for headless mode)
|
||||
.EXAMPLE
|
||||
Restore an openHAB instance from the latest backup file
|
||||
Restore-openHAB
|
||||
.EXAMPLE
|
||||
Restore the openHAB distribution in the C:\openHAB2 directory from c:\openHAB2-backup\backup.zip without any user interaction
|
||||
Restore-openHAB -OHDirectory C:\openHAB2 -OHBackups c:\openHAB2-backup -FileName backup.zip -AutoConfirm $true
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHDirectory = ".",
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHBackups = "",
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$FileName = "",
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[boolean]$AutoConfirm = $False
|
||||
)
|
||||
|
||||
begin {}
|
||||
process {
|
||||
|
||||
Import-Module $PSScriptRoot\common.psm1 -Force
|
||||
|
||||
Write-Host ""
|
||||
BoxMessage "openHAB 2.x.x restore script" Magenta
|
||||
Write-Host ""
|
||||
|
||||
try {
|
||||
$StartDir = Get-Location -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Can't retrieve the current location - exiting" $_
|
||||
}
|
||||
|
||||
# Check for admin (commented out - don't think we need it)
|
||||
# CheckForAdmin
|
||||
|
||||
# Check for openhab running
|
||||
CheckOpenHABRunning
|
||||
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Checking the specified openHAB directory"
|
||||
$OHDirectory = GetOpenHABRoot $OHDirectory
|
||||
if ($OHDirectory -eq "") {
|
||||
exit PrintAndReturn "Could not find the userdata directory! Make sure you are in the openHAB directory or specify the -OHDirectory parameter!"
|
||||
}
|
||||
|
||||
$OHConf = GetOpenHABDirectory "OPENHAB_CONF" "$OHDirectory\conf"
|
||||
$OHUserData = GetOpenHABDirectory "OPENHAB_USERDATA" "$OHDirectory\userdata"
|
||||
|
||||
if (([string]::IsNullOrEmpty($OHBackups))) {
|
||||
$OHBackups = GetOpenHABDirectory "OPENHAB_BACKUPS" "$OHDirectory\backups"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHConf -PathType Container)) {
|
||||
exit PrintAndReturn "Configuration directory does not exist: $OHConf"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHUserData -PathType Container)) {
|
||||
exit PrintAndReturn "Userdata directory does not exist: $OHUserData"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHBackups -PathType Container)) {
|
||||
exit PrintAndReturn "Backups directory does not exist: $OHBackups"
|
||||
}
|
||||
|
||||
|
||||
if ([string]::IsNullOrEmpty($FileName)) {
|
||||
Write-Host -ForegroundColor Yellow "No backup file specified. Finding latest backup: " -NoNewline
|
||||
$FileName = Get-ChildItem -Path $OHBackups -Filter *.zip | Sort LastWriteTime -Descending | Select -Exp Name -First 1
|
||||
Write-Host -ForegroundColor Green $FileName
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($FileName)) {
|
||||
throw "No backup filename was specified and no files were found in the $OHBackups - ending"
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Changing location to $OHDirectory"
|
||||
try {
|
||||
Set-Location -Path $OHDirectory
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Could not change location to $OHDirectory - exiting" $_
|
||||
}
|
||||
|
||||
$TempDir = "$(GetOpenHABTempDirectory)\restore"
|
||||
Write-Host -ForegroundColor Cyan "Creating temporary restore directory $TempDir"
|
||||
try {
|
||||
CreateDirectory $TempDir
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Could not create directory $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Yellow "Using $OHConf as conf folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHUserData as userdata folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHBackups as backups folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $TempDir as temporary restore directory"
|
||||
|
||||
$ArchiveName = Join-Path $OHBackups $FileName
|
||||
|
||||
$Failed = $False
|
||||
try {
|
||||
try {
|
||||
Expand-Archive -Path $ArchiveName -DestinationPath $TempDir -Force -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
return PrintAndThrow "Could not unzip $ArchiveName to $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
try {
|
||||
Get-Content "$TempDir\backup.properties" -ErrorAction Stop | ForEach-Object {
|
||||
$idx = $_.IndexOf("=")
|
||||
if ($idx -ge 0) {
|
||||
$propName = $_.Substring(0, $idx)
|
||||
$propValue = $_.Substring($idx + 1);
|
||||
if ($propName -eq "version") {
|
||||
$BackupVersion = $propValue
|
||||
}
|
||||
ElseIf ($propName -eq "timestamp") {
|
||||
$BackupTime = $propValue
|
||||
}
|
||||
ElseIf ($propName -eq "user") {
|
||||
$OHUser = $propValue
|
||||
}
|
||||
ElseIf ($propName -eq "group") {
|
||||
$OHGroup = $propValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return PrintAndThrow "Error occurred reading/processing $TempDir\backup.properties - exiting" $_
|
||||
}
|
||||
|
||||
$CurrentVersion = GetOpenHABVersion $OHUserData
|
||||
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan " Backup Information:"
|
||||
Write-Host -ForegroundColor Cyan " -------------------"
|
||||
Write-Host -ForegroundColor Cyan " Backup File | " -NoNewline
|
||||
Write-Host -ForegroundColor Yellow $FileName
|
||||
Write-Host -ForegroundColor Cyan " Backup Version | " -NoNewline
|
||||
Write-Host -ForegroundColor Yellow "$BackupVersion (You are on $CurrentVersion)"
|
||||
Write-Host -ForegroundColor Cyan " Backup Timestamp | " -NoNewline
|
||||
Write-Host -ForegroundColor Yellow $BackupTime
|
||||
Write-Host -ForegroundColor Cyan " Config belongs to user | " -NoNewline
|
||||
Write-Host -ForegroundColor Yellow $OHUser
|
||||
Write-Host -ForegroundColor Cyan " from group | " -NoNewline
|
||||
Write-Host -ForegroundColor Yellow $OHGroup
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan "Any existing files with the same name will be replaced."
|
||||
Write-Host -ForegroundColor Cyan "Any file without a replacement will be deleted."
|
||||
Write-Host ""
|
||||
|
||||
if (-Not $AutoConfirm) {
|
||||
$confirmation = Read-Host "Okay to Continue? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling restore"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Copying the $TempDir\conf to $OHConf"
|
||||
try {
|
||||
# Replace the entire directory
|
||||
DeleteIfExists "$OHConf\*" $True
|
||||
Copy-Item -Path "$TempDir\conf\*" -Destination $OHConf -Force -Recurse -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
return PrintAndThrow "Error copy $TempDir\conf to $OHConf - exiting" $_
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Copying the $TempDir\userdata to $OHUserData"
|
||||
try {
|
||||
# Remove everything not in the 'etc' directory (or backups if user put the backups there)
|
||||
# Will overwrite existing files in 'etc' leaving any non-match (ie new) files intact
|
||||
Get-ChildItem -Path "$OHUserData\" -Recurse -ErrorAction Stop | Where-Object { (($_.FullName -NotMatch ".*\\etc\\*.*") -and ($_.FullName -NotMatch ".*\\backups\\*.*")) } | ForEach-Object {
|
||||
DeleteIfExists $_.fullname
|
||||
}
|
||||
Copy-Item -Path "$TempDir\userdata\*" -Destination $OHUserData -Recurse -Force -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
return PrintAndThrow "Error copy $TempDir\userdata to $OHUserData - exiting" $_
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Restore has completed"
|
||||
|
||||
} catch {
|
||||
# Exception occurred
|
||||
$Failed = $True
|
||||
exit -1
|
||||
}
|
||||
finally {
|
||||
$confirmation = 'n'
|
||||
if ($Failed -eq $True) {
|
||||
Write-Host -ForegroundColor Yellow "Error restoring from $TempDir"
|
||||
$confirmation = Read-Host "Do you wish remove the temporary directory (choose 'n' to restore the files yourself)? [y/N]"
|
||||
}
|
||||
|
||||
if (($Failed -eq $False) -or ($AutoConfirm -eq $True) -or ($confirmation -eq 'y')) {
|
||||
$parent = (Get-Item $TempDir).Parent.FullName
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary directory $TempDir"
|
||||
DeleteIfExists $TempDir $True
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $TempDir - delete it manually"
|
||||
}
|
||||
|
||||
try {
|
||||
if (-Not (Test-Path "$parent\*")) {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary directory $parent"
|
||||
DeleteIfExists $parent $True
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $parent - delete it manually"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Setting location back to $StartDir"
|
||||
Set-Location -Path $StartDir -ErrorAction Continue
|
||||
}
|
||||
}
|
||||
}
|
||||
162
runtime/bin/setenv
Normal file
162
runtime/bin/setenv
Normal file
@@ -0,0 +1,162 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
#
|
||||
# handle specific scripts; the SCRIPT_NAME is exactly the name of the Karaf
|
||||
# script: client, instance, shell, start, status, stop, karaf
|
||||
#
|
||||
# if [ "${KARAF_SCRIPT}" == "SCRIPT_NAME" ]; then
|
||||
# Actions go here...
|
||||
# fi
|
||||
|
||||
#
|
||||
# general settings which should be applied for all scripts go here; please keep
|
||||
# in mind that it is possible that scripts might be executed more than once, e.g.
|
||||
# in example of the start script where the start script is executed first and the
|
||||
# karaf script afterwards.
|
||||
#
|
||||
|
||||
#
|
||||
# The following section shows the possible configuration options for the default
|
||||
# karaf scripts
|
||||
#
|
||||
# export JAVA_HOME # Location of Java installation
|
||||
# export JAVA_MIN_MEM # Minimum memory for the JVM
|
||||
# export JAVA_MAX_MEM # Maximum memory for the JVM
|
||||
# export JAVA_PERM_MEM # Minimum perm memory for the JVM
|
||||
# export JAVA_MAX_PERM_MEM # Maximum perm memory for the JVM
|
||||
# export EXTRA_JAVA_OPTS # Additional JVM options
|
||||
# export KARAF_HOME # Karaf home folder
|
||||
# export KARAF_DATA # Karaf data folder
|
||||
# export KARAF_BASE # Karaf base folder
|
||||
# export KARAF_ETC # Karaf etc folder
|
||||
# export KARAF_SYSTEM_OPTS # First citizen Karaf options
|
||||
# export KARAF_OPTS # Additional available Karaf options
|
||||
# export KARAF_DEBUG # Enable debug mode
|
||||
# export KARAF_REDIRECT # Enable/set the std/err redirection when using bin/start
|
||||
# export KARAF_NOROOT # Prevent execution as root if set to true
|
||||
|
||||
#
|
||||
# Import openHAB 2 directory layout
|
||||
#
|
||||
. "$DIRNAME/oh2_dir_layout"
|
||||
|
||||
#
|
||||
# Import Karaf shared functions
|
||||
#
|
||||
. "$DIRNAME/inc"
|
||||
|
||||
#
|
||||
# set listen address for HTTP(S) server
|
||||
#
|
||||
if [ ! -z ${OPENHAB_HTTP_ADDRESS} ]; then
|
||||
HTTP_ADDRESS=${OPENHAB_HTTP_ADDRESS}
|
||||
else
|
||||
HTTP_ADDRESS=0.0.0.0
|
||||
fi
|
||||
|
||||
#
|
||||
# set ports for HTTP(S) server
|
||||
#
|
||||
if [ ! -z ${OPENHAB_HTTP_PORT} ]; then
|
||||
HTTP_PORT=${OPENHAB_HTTP_PORT}
|
||||
else
|
||||
HTTP_PORT=8080
|
||||
fi
|
||||
|
||||
if [ ! -z ${OPENHAB_HTTPS_PORT} ]; then
|
||||
HTTPS_PORT=${OPENHAB_HTTPS_PORT}
|
||||
else
|
||||
HTTPS_PORT=8443
|
||||
fi
|
||||
|
||||
#
|
||||
# set java options
|
||||
#
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS}
|
||||
-Dopenhab.home=${OPENHAB_HOME}
|
||||
-Dopenhab.conf=${OPENHAB_CONF}
|
||||
-Dopenhab.runtime=${OPENHAB_RUNTIME}
|
||||
-Dopenhab.userdata=${OPENHAB_USERDATA}
|
||||
-Dopenhab.logdir=${OPENHAB_LOGDIR}
|
||||
-Dfelix.cm.dir=${OPENHAB_USERDATA}/config
|
||||
-Djava.library.path=${OPENHAB_USERDATA}/tmp/lib
|
||||
-Djetty.host=${HTTP_ADDRESS}
|
||||
-Djetty.http.compliance=RFC2616
|
||||
-Dorg.ops4j.pax.web.listening.addresses=${HTTP_ADDRESS}
|
||||
-Dorg.osgi.service.http.port=${HTTP_PORT}
|
||||
-Dorg.osgi.service.http.port.secure=${HTTPS_PORT}"
|
||||
|
||||
#
|
||||
# set JVM options
|
||||
#
|
||||
ARCH=`uname -m`
|
||||
EXTRA_JAVA_OPTS_COMMON="-Djava.awt.headless=true"
|
||||
EXTRA_JAVA_OPTS_ARCH=""
|
||||
case "$ARCH" in
|
||||
*arm*) ;;
|
||||
*aarch*) ;;
|
||||
*) EXTRA_JAVA_OPTS_ARCH="-XX:+UseG1GC" ;;
|
||||
esac
|
||||
export EXTRA_JAVA_OPTS="${EXTRA_JAVA_OPTS_COMMON} ${EXTRA_JAVA_OPTS_ARCH} ${EXTRA_JAVA_OPTS}"
|
||||
|
||||
|
||||
# The functions below are modified from the Karaf inc script to set JAVA_HOME to a default value.
|
||||
# This avoids Karaf printing a warning message at startup.
|
||||
|
||||
die() {
|
||||
# echo and exit, && command true delays the exit for systemd logging (workaround).
|
||||
echo "$*" && command true
|
||||
exit 1
|
||||
}
|
||||
|
||||
locateJava() {
|
||||
# Setup the Java Virtual Machine
|
||||
if ${cygwin} ; then
|
||||
[ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")
|
||||
[ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")
|
||||
fi
|
||||
|
||||
if [ "x${JAVA_HOME}" = "x" ] && [ "${darwin}" = "true" ]; then
|
||||
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
|
||||
fi
|
||||
if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=$(java-config --jre-home)
|
||||
fi
|
||||
if [ "x${JAVA}" = "x" ]; then
|
||||
if [ "x${JAVA_HOME}" != "x" ]; then
|
||||
if [ ! -d "${JAVA_HOME}" ]; then
|
||||
die "JAVA_HOME is not valid: ${JAVA_HOME}"
|
||||
fi
|
||||
JAVA="${JAVA_HOME}/bin/java"
|
||||
else
|
||||
JAVA=$(command -v java)
|
||||
if [ "x${JAVA}" = "x" ]; then
|
||||
die "java command not found"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "x${JAVA_HOME}" = "x" ]; then
|
||||
JAVA_HOME="$(dirname "$(dirname "$(pathCanonical "${JAVA}")")")"
|
||||
fi
|
||||
}
|
||||
|
||||
detectOS
|
||||
locateJava
|
||||
checkJvmVersion
|
||||
220
runtime/bin/setenv.bat
Normal file
220
runtime/bin/setenv.bat
Normal file
@@ -0,0 +1,220 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
rem
|
||||
rem handle specific scripts; the SCRIPT_NAME is exactly the name of the Karaf
|
||||
rem script; for example karaf.bat, start.bat, stop.bat, admin.bat, client.bat, ...
|
||||
rem
|
||||
rem if "%KARAF_SCRIPT%" == "SCRIPT_NAME" (
|
||||
rem Actions go here...
|
||||
rem )
|
||||
|
||||
rem
|
||||
rem general settings which should be applied for all scripts go here; please keep
|
||||
rem in mind that it is possible that scripts might be executed more than once, e.g.
|
||||
rem in example of the start script where the start script is executed first and the
|
||||
rem karaf script afterwards.
|
||||
rem
|
||||
|
||||
rem
|
||||
rem The following section shows the possible configuration options for the default
|
||||
rem karaf scripts
|
||||
rem
|
||||
rem Window name of the windows console
|
||||
rem SET KARAF_TITLE
|
||||
rem Location of Java installation
|
||||
rem SET JAVA_HOME
|
||||
rem Minimum memory for the JVM
|
||||
rem SET JAVA_MIN_MEM
|
||||
rem Maximum memory for the JVM
|
||||
rem SET JAVA_MAX_MEM
|
||||
rem Minimum perm memory for the JVM
|
||||
rem SET JAVA_PERM_MEM
|
||||
rem Maximum perm memory for the JVM
|
||||
rem SET JAVA_MAX_PERM_MEM
|
||||
rem Additional JVM options
|
||||
rem SET EXTRA_JAVA_OPTS
|
||||
rem Karaf home folder
|
||||
rem SET KARAF_HOME
|
||||
rem Karaf data folder
|
||||
rem SET KARAF_DATA
|
||||
rem Karaf base folder
|
||||
rem SET KARAF_BASE
|
||||
rem Karaf etc folder
|
||||
rem SET KARAF_ETC
|
||||
rem First citizen Karaf options
|
||||
rem SET KARAF_SYSTEM_OPTS
|
||||
rem Additional available Karaf options
|
||||
rem SET KARAF_OPTS
|
||||
rem Enable debug mode
|
||||
rem SET KARAF_DEBUG
|
||||
|
||||
:: Use openHAB 2 directory layout
|
||||
call "%DIRNAME%oh2_dir_layout.bat"
|
||||
|
||||
:: set listen address for HTTP(S) server
|
||||
:check_http_address
|
||||
IF NOT [%OPENHAB_HTTP_ADDRESS%] == [] GOTO :http_address_set
|
||||
set HTTP_ADDRESS=0.0.0.0
|
||||
goto :http_address_done
|
||||
|
||||
:http_address_set
|
||||
set HTTP_ADDRESS=%OPENHAB_HTTP_ADDRESS%
|
||||
goto :http_address_done
|
||||
|
||||
:http_address_done
|
||||
|
||||
:: set ports for HTTP(S) server
|
||||
:check_http_port
|
||||
IF NOT [%OPENHAB_HTTP_PORT%] == [] GOTO :http_port_set
|
||||
set HTTP_PORT=8080
|
||||
goto :http_port_done
|
||||
|
||||
:http_port_set
|
||||
set HTTP_PORT=%OPENHAB_HTTP_PORT%
|
||||
goto :http_port_done
|
||||
|
||||
:http_port_done
|
||||
|
||||
:check_https_port
|
||||
IF NOT [%OPENHAB_HTTPS_PORT%] == [] GOTO :https_port_set
|
||||
set HTTPS_PORT=8443
|
||||
goto :https_port_done
|
||||
|
||||
:https_port_set
|
||||
set HTTPS_PORT=%OPENHAB_HTTPS_PORT%
|
||||
goto :https_port_done
|
||||
|
||||
:https_port_done
|
||||
|
||||
:: set java options
|
||||
set JAVA_OPTS=%JAVA_OPTS% ^
|
||||
-Dopenhab.home=%OPENHAB_HOME% ^
|
||||
-Dopenhab.conf=%OPENHAB_CONF% ^
|
||||
-Dopenhab.runtime=%OPENHAB_RUNTIME% ^
|
||||
-Dopenhab.userdata=%OPENHAB_USERDATA% ^
|
||||
-Dopenhab.logdir=%OPENHAB_LOGDIR% ^
|
||||
-Dfelix.cm.dir=%OPENHAB_USERDATA%\config ^
|
||||
-Djava.library.path=%OPENHAB_USERDATA%\tmp\lib ^
|
||||
-Djetty.host=%HTTP_ADDRESS% ^
|
||||
-Djetty.http.compliance=RFC2616 ^
|
||||
-Dorg.ops4j.pax.web.listening.addresses=%HTTP_ADDRESS% ^
|
||||
-Dorg.osgi.service.http.port=%HTTP_PORT% ^
|
||||
-Dorg.osgi.service.http.port.secure=%HTTPS_PORT%
|
||||
|
||||
:: set jvm options
|
||||
set EXTRA_JAVA_OPTS=-XX:+UseG1GC ^
|
||||
-Djava.awt.headless=true
|
||||
|
||||
:: set JAVA_HOME if not set yet
|
||||
rem Setup the Java Virtual Machine
|
||||
if not "%JAVA%" == "" goto :Check_JAVA_END
|
||||
if not "%JAVA_HOME%" == "" goto :TryJDKEnd
|
||||
:TryJRE
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
|
||||
if not exist __reg1.txt goto :TryJDK
|
||||
type __reg1.txt | find "CurrentVersion" > __reg2.txt
|
||||
if errorlevel 1 goto :TryJDK
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
|
||||
if errorlevel 1 goto :TryJDK
|
||||
set JavaTemp=%JavaTemp%##
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp:##=%
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\%JavaTemp%"
|
||||
if not exist __reg1.txt goto :TryJDK
|
||||
type __reg1.txt | find "JavaHome" > __reg2.txt
|
||||
if errorlevel 1 goto :TryJDK
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
|
||||
if errorlevel 1 goto :TryJDK
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
goto TryJDKEnd
|
||||
:TryJDK
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
|
||||
if not exist __reg1.txt (
|
||||
goto TryRegJRE
|
||||
)
|
||||
type __reg1.txt | find "CurrentVersion" > __reg2.txt
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JavaTemp=%%~x
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
set JavaTemp=%JavaTemp%##
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp: ##=##%
|
||||
set JavaTemp=%JavaTemp:##=%
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
start /w regedit /e __reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\%JavaTemp%"
|
||||
if not exist __reg1.txt (
|
||||
goto TryRegJRE
|
||||
)
|
||||
type __reg1.txt | find "JavaHome" > __reg2.txt
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
for /f "tokens=2 delims==" %%x in (__reg2.txt) do set JAVA_HOME=%%~x
|
||||
if errorlevel 1 (
|
||||
goto TryRegJRE
|
||||
)
|
||||
del __reg1.txt
|
||||
del __reg2.txt
|
||||
:TryRegJRE
|
||||
rem try getting the JAVA_HOME from registry
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion`) DO (
|
||||
set JAVA_VERSION=%%A
|
||||
)
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\%JAVA_VERSION%" /v JavaHome`) DO (
|
||||
set JAVA_HOME=%%A %%B
|
||||
)
|
||||
if not exist "%JAVA_HOME%" (
|
||||
goto TryRegJDK
|
||||
)
|
||||
goto TryJDKEnd
|
||||
:TryRegJDK
|
||||
rem try getting the JAVA_HOME from registry
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Development Kit" /v CurrentVersion`) DO (
|
||||
set JAVA_VERSION=%%A
|
||||
)
|
||||
FOR /F "usebackq tokens=3*" %%A IN (`REG QUERY "HKLM\Software\JavaSoft\Java Development Kit\%JAVA_VERSION%" /v JavaHome`) DO (
|
||||
set JAVA_HOME=%%A %%B
|
||||
)
|
||||
if not exist "%JAVA_HOME%" (
|
||||
echo Unable to retrieve JAVA_HOME from Registry
|
||||
)
|
||||
goto TryJDKEnd
|
||||
:TryJDKEnd
|
||||
if not exist "%JAVA_HOME%" (
|
||||
echo JAVA_HOME is not valid: "%JAVA_HOME%"
|
||||
goto END
|
||||
)
|
||||
set JAVA=%JAVA_HOME%\bin\java
|
||||
:Check_JAVA_END
|
||||
143
runtime/bin/shell
Normal file
143
runtime/bin/shell
Normal file
@@ -0,0 +1,143 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
setupClassPath() {
|
||||
# Setup classpath
|
||||
CLASSPATH="${KARAF_HOME}/system/org/apache/karaf/shell/org.apache.karaf.shell.core/4.2.1/org.apache.karaf.shell.core-4.2.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/ops4j/pax/logging/pax-logging-api/1.10.1/pax-logging-api-1.10.1.jar"
|
||||
CLASSPATH="${CLASSPATH}:${KARAF_HOME}/system/org/jline/jline/3.9.0/jline-3.9.0.jar"
|
||||
}
|
||||
|
||||
init() {
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Unlimit the number of file descriptors if possible
|
||||
unlimitFD
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
|
||||
# Locate the Karaf base directory
|
||||
locateBase
|
||||
|
||||
# Locate the Karaf data directory
|
||||
locateData
|
||||
|
||||
# Locate the Karaf etc directory
|
||||
locateEtc
|
||||
|
||||
# Setup the native library path
|
||||
setupNativePath
|
||||
|
||||
# Locate the Java VM to execute
|
||||
locateJava
|
||||
|
||||
# Determine the JVM vendor
|
||||
detectJVM
|
||||
|
||||
# Setup default options
|
||||
setupDefaults
|
||||
|
||||
# Setup classpath
|
||||
setupClassPath
|
||||
|
||||
# Install debug options
|
||||
setupDebugOptions
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
exec "${JAVA}" ${JAVA_OPTS} \
|
||||
-Dkaraf.instances="${KARAF_HOME}/instances" \
|
||||
-Dkaraf.home="${KARAF_HOME}" \
|
||||
-Dkaraf.base="${KARAF_BASE}" \
|
||||
-Dkaraf.etc="${KARAF_ETC}" \
|
||||
-Dkaraf.data="${KARAF_DATA}" \
|
||||
-Djava.io.tmpdir="${KARAF_DATA}/tmp" \
|
||||
-Djava.util.logging.config.file="${KARAF_BASE}/etc/java.util.logging.properties" \
|
||||
${KARAF_OPTS} \
|
||||
${OPTS} \
|
||||
-classpath "${CLASSPATH}" \
|
||||
org.apache.karaf.shell.impl.console.standalone.Main --classpath="$KARAF_HOME/system" "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
143
runtime/bin/shell.bat
Normal file
143
runtime/bin/shell.bat
Normal file
@@ -0,0 +1,143 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="shell.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
rem Check/Set up some easily accessible MIN/MAX params for JVM mem usage
|
||||
if "%JAVA_MIN_MEM%" == "" (
|
||||
set JAVA_MIN_MEM=128M
|
||||
)
|
||||
if "%JAVA_MAX_MEM%" == "" (
|
||||
set JAVA_MAX_MEM=512M
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
set DEFAULT_JAVA_OPTS=
|
||||
set DEFAULT_JAVA_DEBUG_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
|
||||
|
||||
rem Support for loading native libraries
|
||||
set PATH=%PATH%;%KARAF_BASE%\lib;%KARAF_HOME%\lib
|
||||
|
||||
rem Setup the Java Virtual Machine
|
||||
if not "%JAVA%" == "" goto :Check_JAVA_END
|
||||
set JAVA=java
|
||||
if "%JAVA_HOME%" == "" call :warn JAVA_HOME not set; results may vary
|
||||
if not "%JAVA_HOME%" == "" set JAVA=%JAVA_HOME%\bin\java
|
||||
if not exist "%JAVA_HOME%" (
|
||||
call :warn JAVA_HOME is not valid: "%JAVA_HOME%"
|
||||
goto END
|
||||
)
|
||||
:Check_JAVA_END
|
||||
|
||||
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
|
||||
|
||||
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
|
||||
set JAVA_OPTS=%JAVA_OPTS% %EXTRA_JAVA_OPTS%
|
||||
:KARAF_EXTRA_JAVA_OPTS_END
|
||||
|
||||
if "%KARAF_DEBUG%" == "" goto :KARAF_DEBUG_END
|
||||
rem Use the defaults if JAVA_DEBUG_OPTS was not set
|
||||
if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
|
||||
|
||||
set JAVA_OPTS="%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
|
||||
call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
|
||||
:KARAF_DEBUG_END
|
||||
|
||||
set CLASSPATH=%KARAF_HOME%\system\org\apache\karaf\shell\org.apache.karaf.shell.core\4.2.1\org.apache.karaf.shell.core-4.2.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\ops4j\pax\logging\pax-logging-api\1.10.1\pax-logging-api-1.10.1.jar
|
||||
set CLASSPATH=%CLASSPATH%;%KARAF_HOME%\system\org\jline\jline\3.9.0\jline-3.9.0.jar
|
||||
|
||||
:EXECUTE
|
||||
if "%SHIFT%" == "true" SET ARGS=%2 %3 %4 %5 %6 %7 %8
|
||||
if not "%SHIFT%" == "true" SET ARGS=%1 %2 %3 %4 %5 %6 %7 %8
|
||||
rem Execute the Java Virtual Machine
|
||||
"%JAVA%" %JAVA_OPTS% %OPTS% -classpath "%CLASSPATH%" -Dkaraf.instances="%KARAF_HOME%\instances" -Dkaraf.home="%KARAF_HOME%" -Dkaraf.base="%KARAF_BASE%" -Dkaraf.etc="%KARAF_ETC%" -Dkaraf.data="%KARAF_DATA%" -Djava.io.tmpdir="%KARAF_DATA%\tmp" -Djava.util.logging.config.file="%KARAF_BASE%\etc\java.util.logging.properties" %KARAF_OPTS% org.apache.karaf.shell.impl.console.standalone.Main --classpath="%KARAF_HOME%\system" %ARGS%
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
103
runtime/bin/start
Normal file
103
runtime/bin/start
Normal file
@@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
init() {
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
|
||||
# Enable redirect
|
||||
if [ "x${KARAF_REDIRECT}" != "x" ]; then
|
||||
warn "Redirecting Karaf output to ${KARAF_REDIRECT}"
|
||||
else
|
||||
KARAF_REDIRECT="/dev/null"
|
||||
fi
|
||||
|
||||
exec "${KARAF_HOME}/bin/karaf" server "$@" >> "${KARAF_REDIRECT}" 2>&1 &
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
98
runtime/bin/start.bat
Normal file
98
runtime/bin/start.bat
Normal file
@@ -0,0 +1,98 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="start.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
if "%KARAF_TITLE%" == "" (
|
||||
set "KARAF_TITLE=Karaf"
|
||||
)
|
||||
|
||||
:EXECUTE
|
||||
start "%KARAF_TITLE%" /MIN "%KARAF_HOME%\bin\karaf.bat" server %*
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
if not "%PAUSE%" == "" pause
|
||||
|
||||
:END_NO_PAUSE
|
||||
|
||||
98
runtime/bin/status
Normal file
98
runtime/bin/status
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
init() {
|
||||
# KARAF-5332: Unset KARAF_DEBUG
|
||||
unset KARAF_DEBUG
|
||||
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
exec "${KARAF_HOME}/bin/karaf" status "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
100
runtime/bin/status.bat
Normal file
100
runtime/bin/status.bat
Normal file
@@ -0,0 +1,100 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="status.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
:EXECUTE
|
||||
"%KARAF_HOME%\bin\karaf.bat" status
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
if not "%PAUSE%" == "" pause
|
||||
|
||||
:END_NO_PAUSE
|
||||
98
runtime/bin/stop
Normal file
98
runtime/bin/stop
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
|
||||
realpath() {
|
||||
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
|
||||
AWK=awk
|
||||
if ${solaris}; then
|
||||
if [ -x /usr/xpg4/bin/awk ]; then
|
||||
AWK=/usr/xpg4/bin/awk
|
||||
elif [ -x /usr/bin/nawk ]; then
|
||||
AWK=/usr/bin/nawk
|
||||
fi
|
||||
fi
|
||||
|
||||
READLINK_EXISTS=$(command -v readlink &> /dev/null)
|
||||
if [ -z "$READLINK_EXISTS" ]; then
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
else
|
||||
OURPWD=${PWD}
|
||||
cd "$(dirname "${1}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
while [ "${LINK}" ]; do
|
||||
echo "link: ${LINK}" >&2
|
||||
cd "$(dirname "${LINK}")" || exit 2
|
||||
LINK=$(readlink "$(basename "${1}")")
|
||||
done
|
||||
REALPATH="${PWD}/$(basename "${1}")"
|
||||
cd "${OURPWD}" || exit 2
|
||||
echo "${REALPATH}"
|
||||
fi
|
||||
}
|
||||
|
||||
REALNAME=$(realpath "$0")
|
||||
DIRNAME=$(dirname "${REALNAME}")
|
||||
PROGNAME=$(basename "${REALNAME}")
|
||||
|
||||
#
|
||||
# Load common functions
|
||||
#
|
||||
. "${DIRNAME}/inc"
|
||||
|
||||
#
|
||||
# Sourcing environment settings for karaf similar to tomcats setenv
|
||||
#
|
||||
KARAF_SCRIPT="${PROGNAME}"
|
||||
export KARAF_SCRIPT
|
||||
if [ -f "${DIRNAME}/setenv" ]; then
|
||||
. "${DIRNAME}/setenv"
|
||||
fi
|
||||
|
||||
init() {
|
||||
# KARAF-5332: Unset KARAF_DEBUG
|
||||
unset KARAF_DEBUG
|
||||
|
||||
# Determine if there is special OS handling we must perform
|
||||
detectOS
|
||||
|
||||
# Locate the Karaf home directory
|
||||
locateHome
|
||||
}
|
||||
|
||||
run() {
|
||||
convertPaths
|
||||
exec "${KARAF_HOME}/bin/karaf" stop "$@"
|
||||
}
|
||||
|
||||
main() {
|
||||
init
|
||||
run "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
100
runtime/bin/stop.bat
Normal file
100
runtime/bin/stop.bat
Normal file
@@ -0,0 +1,100 @@
|
||||
@echo off
|
||||
rem
|
||||
rem
|
||||
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
rem contributor license agreements. See the NOTICE file distributed with
|
||||
rem this work for additional information regarding copyright ownership.
|
||||
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
rem (the "License"); you may not use this file except in compliance with
|
||||
rem the License. You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem
|
||||
|
||||
if not "%ECHO%" == "" echo %ECHO%
|
||||
|
||||
setlocal
|
||||
set DIRNAME=%~dp0%
|
||||
set PROGNAME=%~nx0%
|
||||
set ARGS=%*
|
||||
|
||||
rem Sourcing environment settings for karaf similar to tomcats setenv
|
||||
SET KARAF_SCRIPT="stop.bat"
|
||||
if exist "%DIRNAME%setenv.bat" (
|
||||
call "%DIRNAME%setenv.bat"
|
||||
)
|
||||
|
||||
rem Check console window title. Set to Karaf by default
|
||||
if not "%KARAF_TITLE%" == "" (
|
||||
title %KARAF_TITLE%
|
||||
) else (
|
||||
title Karaf
|
||||
)
|
||||
|
||||
goto BEGIN
|
||||
|
||||
:warn
|
||||
echo %PROGNAME%: %*
|
||||
goto :EOF
|
||||
|
||||
:BEGIN
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if not "%KARAF_HOME%" == "" (
|
||||
call :warn Ignoring predefined value for KARAF_HOME
|
||||
)
|
||||
set KARAF_HOME=%DIRNAME%..
|
||||
if not exist "%KARAF_HOME%" (
|
||||
call :warn KARAF_HOME is not valid: "%KARAF_HOME%"
|
||||
goto END
|
||||
)
|
||||
|
||||
if not "%KARAF_BASE%" == "" (
|
||||
if not exist "%KARAF_BASE%" (
|
||||
call :warn KARAF_BASE is not valid: "%KARAF_BASE%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_BASE%" == "" (
|
||||
set "KARAF_BASE=%KARAF_HOME%"
|
||||
)
|
||||
|
||||
if not "%KARAF_DATA%" == "" (
|
||||
if not exist "%KARAF_DATA%" (
|
||||
call :warn KARAF_DATA is not valid: "%KARAF_DATA%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_DATA%" == "" (
|
||||
set "KARAF_DATA=%KARAF_BASE%\data"
|
||||
)
|
||||
|
||||
if not "%KARAF_ETC%" == "" (
|
||||
if not exist "%KARAF_ETC%" (
|
||||
call :warn KARAF_ETC is not valid: "%KARAF_ETC%"
|
||||
goto END
|
||||
)
|
||||
)
|
||||
if "%KARAF_ETC%" == "" (
|
||||
set "KARAF_ETC=%KARAF_BASE%\etc"
|
||||
)
|
||||
|
||||
:EXECUTE
|
||||
"%KARAF_HOME%\bin\karaf.bat" stop
|
||||
|
||||
rem # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
:END
|
||||
|
||||
endlocal
|
||||
|
||||
if not "%PAUSE%" == "" pause
|
||||
|
||||
:END_NO_PAUSE
|
||||
351
runtime/bin/update
Normal file
351
runtime/bin/update
Normal file
@@ -0,0 +1,351 @@
|
||||
#!/bin/sh
|
||||
|
||||
setup(){
|
||||
## Keep the script general by allowing the user to provide the version number to download.
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||
echo "Usage: ./runtime/bin/update [VersionNumber] [openHAB Dir]"
|
||||
echo ""
|
||||
echo " e.g. ./runtime/bin/update << Updates to the next version"
|
||||
echo " ./runtime/bin/update 2.0.0 << Updates to a specific version"
|
||||
echo " ./update 2.1.0 /opt/openHAB2 << Updates a specific root folder"
|
||||
echo " ./runtime/bin/update 2.2.0-SNAPSHOT << Updates to latest SNAPSHOT"
|
||||
echo ""
|
||||
echo "Use this script to change openHAB to another version. Specifying the version allows"
|
||||
echo "you to upgrade or downgrade to that version, or to the latest snapshot. Not specifying"
|
||||
echo "any parameters will attempt to find the next version for you."
|
||||
echo ""
|
||||
echo "You can place this script anywhere, but you should run it from inside the openHAB root folder."
|
||||
echo "Do not try to run the script from inside the runtime folder."
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
## Ask to run as root to prevent us from running sudo in this script.
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Please run this script as root! (e.g. use sudo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Second parameter can be the openHAB path, if not assume the script is called from root!
|
||||
if [ -z "$2" ]; then
|
||||
if [ -n "$OPENHAB_HOME" ]; then
|
||||
WorkingDir="$OPENHAB_HOME"
|
||||
DirError="'OPENHAB_HOME' does not point towards openHAB's root directory."
|
||||
else
|
||||
WorkingDir="."
|
||||
DirError="The script must be called from openHAB's root directory."
|
||||
fi
|
||||
else
|
||||
WorkingDir="$2"
|
||||
DirError="The specified directory is not openHAB's root directory."
|
||||
fi
|
||||
|
||||
if [ -z "$OPENHAB_CONF" ]; then OPENHAB_CONF="$WorkingDir/conf"; fi
|
||||
if [ -z "$OPENHAB_USERDATA" ]; then OPENHAB_USERDATA="$WorkingDir/userdata"; fi
|
||||
if [ -z "$OPENHAB_LOGDIR" ]; then OPENHAB_LOGDIR="$OPENHAB_USERDATA/logs"; fi
|
||||
|
||||
## Test to see if the script is being run non-interactively
|
||||
if [ ! -t 0 ] || [ -n "$OPENHAB_NONINTERACT" ] ; then
|
||||
exec > "$OPENHAB_LOGDIR/update.log" 2>&1
|
||||
OPENHAB_NONINTERACT="true"
|
||||
fi
|
||||
|
||||
## Check two of the standard openHAB folders to make sure we're updating the right thing.
|
||||
if [ ! -d "$OPENHAB_USERDATA" ] || [ ! -d "$OPENHAB_CONF" ]; then
|
||||
echo "$DirError" >&2
|
||||
echo "Either specify a directory or place this update script in and run from openHAB's root folder." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Check to see if processes are running before updating
|
||||
if [ ! -z "$(ps aux | grep "openhab2.*java" | grep -v grep)" ]; then
|
||||
echo "openHAB is running! Please stop the process before updating." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CurrentVersion="$(awk '/openhab-distro/{print $3}' "$OPENHAB_USERDATA/etc/version.properties")"
|
||||
|
||||
OHVersion="$1"
|
||||
|
||||
## If no OHVersion is specified, try incrementing the second point.
|
||||
if [ -z "$OHVersion" ]; then
|
||||
FirstPart="$(echo "$CurrentVersion" | awk -F'.' '{print $1}')"
|
||||
SecondPart="$(echo "$CurrentVersion" | awk -F'.' '{print $2}')"
|
||||
ThirdPart="$(echo "$CurrentVersion" | awk -F'.' '{print $3}')"
|
||||
FourthPart="$(echo "$CurrentVersion" | awk -F'.' '{print $4}')"
|
||||
if test "${ThirdPart#*-SNAPSHOT}" != "$ThirdPart"; then
|
||||
OHVersion="$CurrentVersion"
|
||||
elif [ -n "$FourthPart" ]; then
|
||||
OHVersion="$FirstPart.$SecondPart.$ThirdPart"
|
||||
else
|
||||
OHVersion="$FirstPart.$((SecondPart + 1)).$ThirdPart"
|
||||
fi
|
||||
fi
|
||||
|
||||
milestoneVersion="$(echo "$OHVersion" | awk -F'.' '{print $4}')"
|
||||
## Choose bintray for releases, jenkins for snapshots and artifactory for milestones or release candidates.
|
||||
if test "${OHVersion#*-SNAPSHOT}" != "$OHVersion"; then
|
||||
DownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-$OHVersion.zip"
|
||||
AddonsDownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons/target/openhab-addons-$OHVersion.kar"
|
||||
LegacyAddonsDownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons-legacy/target/openhab-addons-legacy-$OHVersion.kar"
|
||||
elif [ "$OHVersion" = "$CurrentVersion" ]; then
|
||||
echo "You are already on openHAB $CurrentVersion" >&2
|
||||
exit 1
|
||||
elif [ -n "$milestoneVersion" ]; then
|
||||
DownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab/$OHVersion/openhab-$OHVersion.zip"
|
||||
AddonsDownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab-addons/$OHVersion/openhab-addons-$OHVersion.kar"
|
||||
LegacyAddonsDownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab-addons-legacy/$OHVersion/openhab-addons-legacy-$OHVersion.kar"
|
||||
else
|
||||
DownloadLocation="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F$OHVersion%2Fopenhab-$OHVersion.zip"
|
||||
AddonsDownloadLocation="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab-addons%2F$OHVersion%2Fopenhab-addons-$OHVersion.kar"
|
||||
LegacyAddonsDownloadLocation="https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab-addons-legacy%2F$OHVersion%2Fopenhab-addons-legacy-$OHVersion.kar"
|
||||
fi
|
||||
|
||||
## Set the temporary directories.
|
||||
TempDir="/tmp/openhab"
|
||||
OutputFile="$TempDir/openhab-$OHVersion.zip"
|
||||
|
||||
## Store anything in temporary folders
|
||||
echo "Making Temporary Directory"
|
||||
mkdir -p "$TempDir" || {
|
||||
echo "Failed to make temporary directory: $TempDir" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
## Download the specified version of openHAB and check for an update script.
|
||||
download(){
|
||||
## Skip this part if the script was called by an older version of itself.
|
||||
if [ "$1" != "--skipnew" ]; then
|
||||
echo "Downloading openHAB $OHVersion..."
|
||||
curl -Lf# "$DownloadLocation" -o "$OutputFile" || {
|
||||
echo "Download failed, version $OHVersion does not exist." >&2
|
||||
echo "If you believe this to be an error, please check the openHAB website. (www.openhab.org)"
|
||||
exit 1
|
||||
}
|
||||
## First check if there's a newer version of this update script
|
||||
unzip -qp "$OutputFile" runtime/bin/update > "$TempDir/update" 2>/dev/null && {
|
||||
echo "Update script in .zip archive found, using that instead."
|
||||
chmod a+x "$TempDir/update"
|
||||
"$TempDir/update" "$OHVersion" "$(cd "$WorkingDir" && pwd -P)" "--skipnew"; exit 0
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
runCommand() {
|
||||
string="$1"
|
||||
string="$(echo "$string" | sed "s:\$OPENHAB_USERDATA:${OPENHAB_USERDATA:?}:g")"
|
||||
string="$(echo "$string" | sed "s:\$OPENHAB_CONF:${OPENHAB_CONF:?}:g")"
|
||||
string="$(echo "$string" | sed "s:\$OPENHAB_HOME:${WorkingDir:?}:g")"
|
||||
|
||||
command="$(echo "$string" | awk -F';' '{print $1}')"
|
||||
param1="$(echo "$string" | awk -F';' '{print $2}')"
|
||||
param2="$(echo "$string" | awk -F';' '{print $3}')"
|
||||
|
||||
case $command in
|
||||
'DEFAULT')
|
||||
# Just rename the file, the update process adds back the new version
|
||||
echo " Adding '.bak' to $param1"
|
||||
mv "$param1" "$param1.bak"
|
||||
;;
|
||||
'DELETE')
|
||||
# We should be strict and specific here, i.e only delete one file.
|
||||
if [ -f "$param1" ]; then
|
||||
echo " Deleting File: $param1"
|
||||
rm -f "$param1"
|
||||
fi
|
||||
;;
|
||||
'DELETEDIR')
|
||||
# We should be strict and specific here, i.e only delete one directory.
|
||||
if [ -d "$param1" ]; then
|
||||
echo " Deleting Directory: $param1"
|
||||
rm -rf "$param1"
|
||||
fi
|
||||
;;
|
||||
'MOVE')
|
||||
echo " Moving: From $param1 to $param2"
|
||||
mv "$param1" "$param2"
|
||||
;;
|
||||
'NOTE') printf ' \033[32mNote:\033[m %s\n' "$param1";;
|
||||
'ALERT') printf ' \033[31mWarning:\033[m %s\n' "$param1";;
|
||||
esac
|
||||
}
|
||||
|
||||
getVersionNumber() {
|
||||
firstPart="$(echo "$1" | awk -F'.' '{print $1}')"
|
||||
secondPart="$(echo "$1" | awk -F'.' '{print $2}')"
|
||||
thirdPart="$(echo "$1" | awk -F'.' '{print $3}')"
|
||||
thirdPart="${thirdPart%%-*}"
|
||||
echo $((firstPart*10000+secondPart*100+thirdPart))
|
||||
}
|
||||
|
||||
scanVersioningList() {
|
||||
Section="$1"
|
||||
VersionMessage="$2"
|
||||
InSection=false
|
||||
InNewVersion=false
|
||||
|
||||
## Read the file line by line.
|
||||
while IFS= read -r Line
|
||||
do
|
||||
case $Line in
|
||||
'')
|
||||
continue
|
||||
;;
|
||||
## Flag to run the relevant [[section]] only.
|
||||
"[[$Section]]")
|
||||
InSection=true
|
||||
;;
|
||||
## Stop reading the file if another [[section]] starts.
|
||||
"[["*"]]")
|
||||
if $InSection; then
|
||||
break
|
||||
fi
|
||||
;;
|
||||
## Detect the [version] and execute the line if relevant.
|
||||
'['*'.'*'.'*']')
|
||||
if $InSection; then
|
||||
LineVersion="$(echo "$Line" | awk -F'[][]' '{print $2}')"
|
||||
LineVersionNumber=$(getVersionNumber "$LineVersion")
|
||||
if [ "$CurrentVersionNumber" -lt "$LineVersionNumber" ]; then
|
||||
InNewVersion=true
|
||||
echo ""
|
||||
echo "$VersionMessage $LineVersion:"
|
||||
else
|
||||
InNewVersion=false
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if $InSection && $InNewVersion; then
|
||||
runCommand "$Line"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < "$TempDir/$transferFile"
|
||||
}
|
||||
|
||||
echo " "
|
||||
echo "#########################################"
|
||||
echo " openHAB 2.x.x update script "
|
||||
echo "#########################################"
|
||||
echo " "
|
||||
|
||||
SpecifiedVersion="$1"
|
||||
SpecifiedDir="$2"
|
||||
SkipModifier="$3"
|
||||
|
||||
##Run the initialisation functions defined above
|
||||
setup "$SpecifiedVersion" "$SpecifiedDir"
|
||||
download "$SkipModifier"
|
||||
|
||||
transferFile="update.lst"
|
||||
CurrentVersionNumber=$(getVersionNumber "$CurrentVersion")
|
||||
case $CurrentVersion in
|
||||
*"-"* | *"."*"."*"."*) CurrentVersionNumber=$((CurrentVersionNumber-1));;
|
||||
esac
|
||||
|
||||
|
||||
## Go through a list of transitional commands that are stored in the update archive.
|
||||
echo "New update list required, extracting from zip..."
|
||||
unzip -qp "$OutputFile" "runtime/bin/$transferFile" > "$TempDir/$transferFile" || {
|
||||
echo "Additional update commands not found in archive, exiting..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Notify the user of important changes first
|
||||
echo "The script will attempt to update openHAB to version $OHVersion"
|
||||
printf 'Please read the following \033[32mnotes\033[m and \033[31mwarnings\033[m:\n'
|
||||
scanVersioningList "MSG" "Important notes for version"
|
||||
|
||||
if [ -z "$OPENHAB_NONINTERACT" ]; then
|
||||
printf '\nIs this okay? [y/N]: '
|
||||
read -r answer
|
||||
case $answer in
|
||||
[Yy]*)
|
||||
;;
|
||||
*)
|
||||
echo "Cancelling update..."
|
||||
rm -rf "${TempDir:?}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
## Preserve file ownership of old setup.
|
||||
FileOwner=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $3}')
|
||||
FileGroup=$(ls -ld "$OPENHAB_USERDATA" | awk '{print $4}')
|
||||
|
||||
## Perform version specific pre-update commands
|
||||
scanVersioningList "PRE" "Performing pre-update tasks for version"
|
||||
|
||||
## Remove only the files that are to be replaced.
|
||||
echo ""
|
||||
echo "Removing openHAB System Files..."
|
||||
mkdir -p "$TempDir/runtime"
|
||||
mkdir -p "$TempDir/userdata/etc"
|
||||
mv "$WorkingDir/runtime" "$TempDir/runtime/"
|
||||
|
||||
## Go through a list of system files that are stored in the update archive.
|
||||
echo "New system filelist required, extracting from zip..."
|
||||
unzip -qp "$OutputFile" runtime/bin/userdata_sysfiles.lst > "$TempDir/filelist.lst" || {
|
||||
echo "System Filelist not found in update, exiting..."
|
||||
exit 1
|
||||
}
|
||||
while IFS= read -r fileName
|
||||
do
|
||||
fullPath="$WorkingDir/userdata/etc/$fileName"
|
||||
if [ -f "$fullPath" ]; then
|
||||
mv "$fullPath" "$TempDir/userdata/etc/"
|
||||
fi
|
||||
done < "$TempDir/filelist.lst"
|
||||
|
||||
## Clearing the cache and tmp folders is necessary for upgrade.
|
||||
echo "Clearing cache..."
|
||||
rm -rf "${OPENHAB_USERDATA:?}/cache"
|
||||
rm -rf "${OPENHAB_USERDATA:?}/tmp"
|
||||
|
||||
## Unzip the downloaded folder into openHAB's directory WITHOUT replacing any existing files.
|
||||
echo "Updating openHAB..."
|
||||
unzip -nq "$OutputFile" -d "$WorkingDir/" || {
|
||||
echo "Failed to unzip archive, restoring system files..." >&2
|
||||
## An error has occured so try to restore openHAB to it's previous state.
|
||||
cp -a "$TempDir/runtime" "$WorkingDir/runtime"
|
||||
cp -a "$TempDir/userdata/etc/"* "${OPENHAB_USERDATA:?}/etc/"
|
||||
exit 1
|
||||
}
|
||||
|
||||
## Perform version specific post-update commands
|
||||
scanVersioningList "POST" "Performing post-update tasks for version"
|
||||
|
||||
## If there's an existing addons file, we need to replace it with the correct version.
|
||||
AddonsFile="$WorkingDir/addons/openhab-addons-$CurrentVersion.kar"
|
||||
if [ -f "$AddonsFile" ]; then
|
||||
echo "Found an openHAB addons file, replacing with new version..."
|
||||
rm -f "${AddonsFile:?}"
|
||||
curl -Lf# "$AddonsDownloadLocation" -o "$WorkingDir/addons/openhab-addons-$OHVersion.kar" || {
|
||||
echo "Download of addons file failed, please find it on the openHAB website (www.openhab.org)" >&2
|
||||
}
|
||||
fi
|
||||
|
||||
## Do the same for the legacy addons file.
|
||||
LegacyAddonsFile="$WorkingDir/addons/openhab-addons-legacy-$CurrentVersion.kar"
|
||||
if [ -f "$LegacyAddonsFile" ]; then
|
||||
echo "Found an openHAB legacy addons file, replacing with new version..."
|
||||
rm -f "${LegacyAddonsFile:?}"
|
||||
curl -Lf# "$LegacyAddonsDownloadLocation" -o "$WorkingDir/addons/openhab-addons-legacy-$OHVersion.kar" || {
|
||||
echo "Download of legacy addons file failed, please find it on the openHAB website (www.openhab.org)" >&2
|
||||
}
|
||||
fi
|
||||
echo ""
|
||||
## Remove the downloaded zip-file.
|
||||
echo "Deleting temporary files..."
|
||||
rm -rf "${TempDir:?}"
|
||||
|
||||
## Restore file ownership.
|
||||
echo "Restoring previous file ownership ($FileOwner:$FileGroup)"
|
||||
chown -R "$FileOwner:$FileGroup" "$WorkingDir"
|
||||
|
||||
echo ""
|
||||
echo "SUCCESS: openHAB updated from $CurrentVersion to $OHVersion"
|
||||
echo ""
|
||||
34
runtime/bin/update.bat
Normal file
34
runtime/bin/update.bat
Normal file
@@ -0,0 +1,34 @@
|
||||
@ECHO off
|
||||
SETLOCAL
|
||||
|
||||
IF "%1"=="?" GOTO printArgs
|
||||
IF "%1"=="\?" GOTO printArgs
|
||||
IF "%1"=="/?" GOTO printArgs
|
||||
|
||||
SET uargs=
|
||||
IF NOT [%1]==[] ( SET uargs=%uargs% -OHVersion %~1% )
|
||||
|
||||
CD %~dp0
|
||||
powershell -ExecutionPolicy Bypass -command "& { . .\update.ps1; Update-openHAB %uargs% }"
|
||||
SET LEVEL=%ERRORLEVEL%
|
||||
|
||||
if %LEVEL% LSS 0 (
|
||||
PAUSE
|
||||
EXIT /B %LEVEL%
|
||||
)
|
||||
EXIT /B 0
|
||||
|
||||
:printArgs
|
||||
ECHO Usage: update.bat {OHVersion}
|
||||
ECHO OHVersion (required) - The version you want to update (2.3, 2.4, etc)
|
||||
ECHO.
|
||||
ECHO Example to update to OH version 2.3.0 stable:
|
||||
ECHO update.bat 2.3.0
|
||||
ECHO.
|
||||
ECHO Example to update to OH version 2.3.0 snapshot:
|
||||
ECHO update.bat 2.3.0-SNAPSHOT
|
||||
ECHO.
|
||||
ECHO Example to update to OH version 2.4.0 milestone:
|
||||
ECHO update.bat 2.4.0-M6
|
||||
ECHO.
|
||||
EXIT /B -1
|
||||
28
runtime/bin/update.lst
Normal file
28
runtime/bin/update.lst
Normal file
@@ -0,0 +1,28 @@
|
||||
[[MSG]]
|
||||
[2.2.0]
|
||||
NOTE;Logging configuration has changed. 'org.ops4j.pax.logging.cfg' has been backed up and restored to defaults!
|
||||
NOTE;*.rules files are now validated upon startup. Files with errors will from now on be logged and ignored by the runtime.
|
||||
|
||||
[2.3.0]
|
||||
ALERT;Nest Binding: The 'camera' Thing Type now has channel groups. Add 'camera#' before the channel ID in the channel UID of existing camera channels. The 'time_to_target_mins' channel of the 'thermostat' Thing Type is renamed to 'time_to_target'
|
||||
ALERT;Oceanic Binding: The 'softener' Thing Type no longer exists and is replaced by the 'serial' and 'ethernet' Thing Types
|
||||
ALERT;Yamaha Receiver Binding: The configuration parameter names now use lower camel case convention. Change 'HOST' to 'host', 'PORT' to 'port' etc
|
||||
|
||||
[2.4.0]
|
||||
ALERT;Astro Binding: The 'kilometer' and 'miles' channels have been replaced by a new 'distance' channel
|
||||
ALERT;Jeelink Binding: The 'currentWatt' and 'maxWatt' channels have been replaced with 'currentPower' and 'maxPower' channels
|
||||
ALERT;WeatherUnderground Binding: A bridge has been added on top of the current things, you need to add a bridge containing your api-key.
|
||||
ALERT;ZWave Binding: Major changes have been merged to support features such as security. All things must be deleted and re-added. Refer to https://community.openhab.org/t/zwave-binding-updates/51080 for further information.
|
||||
ALERT;Synop Binding is now using UoM. 'wind-speed-ms' and 'wind-speed-knots' channels have been replaced by a single 'wind-speed' channel.
|
||||
ALERT;Amazonechocontrol Binding: The account thing does not have settings anymore. You have to login at amazon once again through the proxy server http(s)://<YourOpenHAB>/amazonechocontrol
|
||||
ALERT;Milight Binding: The various available bulb types do not appear in the Paper UI Inbox anymore. The correct bulb need to be added manually. The bulb "zone" is now a configuration. Bulb Things need to be recreated to apply this change.
|
||||
ALERT;Hue emulation: The item to hue ID mapping is no longer stored in files, but in the openHAB storage service. You need to rediscover "devices" in all services that use the hue emulation (Amazon Echo, Google Home, etc).
|
||||
|
||||
[[PRE]]
|
||||
[2.2.0]
|
||||
DEFAULT;$OPENHAB_USERDATA/etc/org.ops4j.pax.logging.cfg
|
||||
|
||||
[[POST]]
|
||||
[2.3.0]
|
||||
DELETE;$OPENHAB_USERDATA/etc/org.openhab.addons.cfg
|
||||
DELETEDIR;$OPENHAB_USERDATA/kar
|
||||
879
runtime/bin/update.ps1
Normal file
879
runtime/bin/update.ps1
Normal file
@@ -0,0 +1,879 @@
|
||||
#Requires -Version 5.0
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Updates openHAB to the latest version.
|
||||
.DESCRIPTION
|
||||
The Update-openHAB function performs the necessary tasks to update openHAB.
|
||||
.PARAMETER OHDirectory
|
||||
The directory where openHAB is installed (default: current directory).
|
||||
.PARAMETER OHVersion
|
||||
The version to upgrade to.
|
||||
.PARAMETER Snapshot
|
||||
DEPRECATED - Upgrade to a snapshot version ($true) or a release version ($false) (default: $false)
|
||||
DEPRECATED - Please specify "-snapshot" in the OHVersion instead (ex: "2.4.0-SNAPSHOT")
|
||||
.PARAMETER AutoConfirm
|
||||
Automatically confirm update (used for headless mode)
|
||||
.EXAMPLE
|
||||
Update the openHAB distribution in the current directory to the current stable version
|
||||
Update-openHAB
|
||||
.EXAMPLE
|
||||
Update the openHAB distribution in the C:\oh-snapshot directory to the next snapshot version
|
||||
Update-openHAB -OHDirectory C:\oh-snapshot -OHVersion 2.3.0-SNAPSHOT
|
||||
#>
|
||||
|
||||
Function Update-openHAB() {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHDirectory = ".",
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[string]$OHVersion,
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[boolean]$Snapshot = $false,
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[boolean]$AutoConfirm = $false,
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[boolean]$SkipNew = $false, # sssh - secret switch ;)
|
||||
[Parameter(ValueFromPipeline = $True)]
|
||||
[boolean]$KeepUpdateScript = $false # sssh - secret switch ;)
|
||||
)
|
||||
|
||||
# Downloads the URL into a file showing a progress meter. Any error will be thrown to the caller
|
||||
|
||||
function DownloadFiles() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $URL,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $OutputFile
|
||||
)
|
||||
|
||||
# Create the request
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
|
||||
$uri = New-Object "System.Uri" "$URL"
|
||||
$request = [System.Net.HttpWebRequest]::Create($uri)
|
||||
$request.set_Timeout(15000)
|
||||
|
||||
#Get the response (along with the total size)
|
||||
$response = $request.GetResponse()
|
||||
$totalLength = [System.Math]::Floor($response.get_ContentLength()/1024)
|
||||
|
||||
try {
|
||||
# Gets the response stream and setup the buffer
|
||||
$responseStream = $response.GetResponseStream()
|
||||
$targetStream = New-Object -TypeName System.IO.FileStream -ArgumentList $Outputfile, Create
|
||||
$buffer = new-object byte[] 10KB
|
||||
|
||||
# Save console settings
|
||||
$startTop = [System.Console]::CursorTop
|
||||
$startVisibility = [System.Console]::CursorVisible
|
||||
$startColor = [System.Console]::ForegroundColor
|
||||
|
||||
# Process each chunk into the output file (updating the progress meter along the way)
|
||||
try {
|
||||
[System.Console]::CursorVisible = $False
|
||||
[System.Console]::ForegroundColor = "Blue"
|
||||
$count = $responseStream.Read($buffer,0,$buffer.length)
|
||||
$downloadedBytes = $count
|
||||
while ($count -gt 0)
|
||||
{
|
||||
$bytes = [System.Math]::Floor($downloadedBytes/1024)
|
||||
$perc = [System.Math]::Floor(($bytes / $totalLength) * 100)
|
||||
[System.Console]::CursorLeft = 0
|
||||
[System.Console]::CursorTop = $startTop
|
||||
[System.Console]::Write("Downloaded {0}K of {1}K [{2}%]", $bytes, $totalLength, $perc)
|
||||
$targetStream.Write($buffer, 0, $count)
|
||||
$count = $responseStream.Read($buffer,0,$buffer.length)
|
||||
$downloadedBytes = $downloadedBytes + $count
|
||||
}
|
||||
Write-Host "`nFinished Download"
|
||||
} finally {
|
||||
# Set the console settings back
|
||||
[System.Console]::CursorVisible = $startVisibility
|
||||
[System.Console]::ForegroundColor = $startColor
|
||||
}
|
||||
} finally {
|
||||
# Cleanup resources
|
||||
if ($targetStream) {
|
||||
$targetStream.Flush()
|
||||
$targetStream.Close()
|
||||
$targetStream.Dispose()
|
||||
}
|
||||
if ($responseStream) {
|
||||
$responseStream.Dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# This function 'normalizes' the version number - creates left 0 padded segments "0000.0000.0000" that can be compared against
|
||||
function NormalizeVersionNumber() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $VersionNumber
|
||||
)
|
||||
|
||||
$parts = $VersionNumber.Split(".")
|
||||
if ($parts.Length -eq 2) {
|
||||
$parts += "0"
|
||||
}
|
||||
if ($parts.Length -ne 3) {
|
||||
throw "$VersionNumber is not formatted correctly (d.d.d)"
|
||||
}
|
||||
|
||||
$rc = "";
|
||||
$parts | ForEach-Object {
|
||||
$rc += $_.PadLeft(5 - $_.Length, '0')
|
||||
$rc += "."
|
||||
}
|
||||
return $rc.Substring(0, $rc.Length - 1)
|
||||
}
|
||||
|
||||
# This function will process a command from the upgrade.lst file (called from ProcessVersionChange)
|
||||
function ProcessCommand() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $Line
|
||||
)
|
||||
|
||||
# Use of global variables (not passed in)
|
||||
$Line = $Line.Replace("`$OPENHAB_USERDATA", $OHUserData)
|
||||
$Line = $Line.Replace("`$OPENHAB_CONF", $OHConf)
|
||||
$Line = $Line.Replace("`$OPENHAB_HOME", $OHDirectory)
|
||||
$Line = $Line.Replace("`$OPENHAB_RUNTIME", $OHRuntime)
|
||||
|
||||
# Split the line into it's distinct parts
|
||||
$parts = $Line.Split(";")
|
||||
|
||||
# blank line - simply return
|
||||
if ($parts.length -eq 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
# If default - rename an item to "x.bak" (assumes a new version of this file will be added by the upgrade process)
|
||||
if ($parts[0] -eq "DEFAULT") {
|
||||
if ($parts.length -le 1) {
|
||||
Write-Host -ForegroundColor Red "Badly formatted: $Line"
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Rename-Item -Path $parts[1] "$parts[1].bak" -ErrorAction Stop
|
||||
Write-Host -ForegroundColor Cyan "$($parts[1]) renamed to $($parts[1]).bak"
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Yellow "Could not rename $($parts[1]) to $($parts[1]).bak"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Deletes an item
|
||||
ElseIf ($parts[0] -eq "DELETEDIR" -or $parts[0] -eq "DELETE") {
|
||||
if ($parts.length -le 1) {
|
||||
Write-Host -ForegroundColor Red "Badly formatted: $Line"
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if ($parts[0] -eq "DELETEDIR") {
|
||||
DeleteIfExists $parts[1] $True
|
||||
} else {
|
||||
DeleteIfExists $parts[1]
|
||||
}
|
||||
Write-Host -ForegroundColor Cyan "Deleted $($parts[1])"
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Yellow "Could not delete $($parts[1])"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Moves an item
|
||||
ElseIf ($parts[0] -eq "MOVE") {
|
||||
if ($parts.length -le 2) {
|
||||
Write-Host -ForegroundColor Red "Badly formatted: $Line"
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Move-Item -Path $parts[1] -Destination $parts[2] -ErrorAction Stop
|
||||
Write-Host -ForegroundColor Cyan "Moved $($parts[1]) to $($parts[2])"
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Yellow "Could not move $($parts[1]) to $($parts[2])"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Shows a note (console message with a green label)
|
||||
ElseIf ($parts[0] -eq "NOTE") {
|
||||
if ($parts.length -le 1) {
|
||||
Write-Host -ForegroundColor Red "Badly formatted: $Line"
|
||||
}
|
||||
else {
|
||||
Write-Host -ForegroundColor Green "Note: " -NoNewLine
|
||||
Write-Host $parts[1]
|
||||
}
|
||||
}
|
||||
# Shows a note (console message with a red label)
|
||||
ElseIf ($parts[0] -eq "ALERT") {
|
||||
if ($parts.length -le 1) {
|
||||
Write-Host -ForegroundColor Red "Badly formatted: $Line"
|
||||
}
|
||||
else {
|
||||
Write-Host -ForegroundColor Red "Warning: " -NoNewLine
|
||||
Write-Host $parts[1]
|
||||
}
|
||||
}
|
||||
Else {
|
||||
Write-Host -ForegroundColor Red "Unknown command: $Line"
|
||||
}
|
||||
}
|
||||
|
||||
# Processes the update.lst file for the specific section, and version (going from x.x.x to x.x.x).
|
||||
# A boolean is returned indicating whether we found any commands or not
|
||||
function ProcessVersionChange() {
|
||||
param(
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $FileName,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $Section,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $VersionMsg,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $OldVersion,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $NewVersion
|
||||
)
|
||||
|
||||
# Flags used
|
||||
$InSection = $false
|
||||
$InNewVersion = $false
|
||||
|
||||
# Normalize our lower/upper versions
|
||||
$NormalizedOldVersion = NormalizeVersionNumber $OldVersion
|
||||
$NormalizedNewVersion = NormalizeVersionNumber $NewVersion
|
||||
|
||||
# FoundSomething is true if we did some action (and is returned to caller)
|
||||
$FoundSomething = $False
|
||||
|
||||
# Loops through the content of the file...
|
||||
Get-Content $FileName -ErrorAction Stop | ForEach-Object {
|
||||
# Skip blank lines
|
||||
if ($_ -ne "") {
|
||||
# If it's OUR section - flip the switch
|
||||
if ($_ -match "\[\[$Section\]\]") {
|
||||
$InSection = $True
|
||||
}
|
||||
# If it's not OUR section - flip it false
|
||||
ElseIf ($_ -match "\[\[.*\]\]") {
|
||||
$InSection = $false
|
||||
$InNewVersion = $false
|
||||
}
|
||||
# If its a version number section
|
||||
ElseIf ($_ -match "\[\d\.*\d\.*\d\]") {
|
||||
# Determine if we are in a section and the version number is greater than our lower bound but less than or equal to our upper bound
|
||||
if ($InSection) {
|
||||
$NormalizedSectionVersion = NormalizeVersionNumber $_.Substring(1, $_.length - 2)
|
||||
$InNewVersion = ($NormalizedSectionVersion -gt $NormalizedOldVersion) -and ($NormalizedSectionVersion -le $NormalizedNewVersion)
|
||||
if ($InNewVersion -and $InSection) {
|
||||
# If so, show that we are processing this section
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan "$VersionMsg $_ :"
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($InSection -and $InNewVersion) {
|
||||
# Woohoo - found a command to process
|
||||
$FoundSomething = $True
|
||||
ProcessCommand $_
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $FoundSomething
|
||||
}
|
||||
|
||||
# Force reimport of common functions (in case of upgrading the script)
|
||||
Import-Module $PSScriptRoot\common.psm1 -Force
|
||||
|
||||
# Write out startup message
|
||||
Write-Host ""
|
||||
BoxMessage "openHAB 2.x.x update script" Magenta
|
||||
Write-Host ""
|
||||
|
||||
# Check for admin (commented out - don't think we need it)
|
||||
# CheckForAdmin
|
||||
|
||||
# Check for openhab running
|
||||
CheckOpenHABRunning
|
||||
|
||||
# Check if service is installed, stop and delete it
|
||||
Write-Host -ForegroundColor Cyan "Checking whether a service exists"
|
||||
try {
|
||||
$service = Get-Service 'openHAB%' -ErrorAction Ignore
|
||||
if ($service) {
|
||||
# Stop and delete the service
|
||||
Write-Host -ForegroundColor Cyan "Stopping the service"
|
||||
Stop-Service $service.Name -Force -ErrorAction Stop
|
||||
Write-Host -ForegroundColor Cyan "Deleting the service"
|
||||
Remove-Service $service.Name -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Could not stop/delete the openHAB windows server - please do that manually and try again" $_
|
||||
}
|
||||
|
||||
|
||||
# Find the proper directory root directory
|
||||
Write-Host -ForegroundColor Cyan "Checking the specified openHAB directory"
|
||||
$OHDirectory = GetOpenHABRoot $OHDirectory
|
||||
if ($OHDirectory -eq "") {
|
||||
exit PrintAndReturn "Could not find the openHAB directory! Make sure you are in the openHAB directory or specify the -OHDirectory parameter!"
|
||||
}
|
||||
|
||||
# Get the various 'other' directories
|
||||
$OHConf = GetOpenHABDirectory "OPENHAB_CONF" "$OHDirectory\conf"
|
||||
$OHUserData = GetOpenHABDirectory "OPENHAB_USERDATA" "$OHDirectory\userdata"
|
||||
$OHRuntime = GetOpenHABDirectory "OPENHAB_RUNTIME" "$OHDirectory\runtime"
|
||||
$OHAddons = GetOpenHABDirectory "OPENHAB_ADDONS" "$OHDirectory\addons"
|
||||
|
||||
# Validate that all the directories exist (and are directories)
|
||||
if (-NOT (Test-Path -Path $OHConf -PathType Container)) {
|
||||
exit PrintAndReturn "Configuration directory does not exist: $OHConf"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHUserData -PathType Container)) {
|
||||
exit PrintAndReturn "Userdata directory does not exist: $OHUserData"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHRuntime -PathType Container)) {
|
||||
exit PrintAndReturn "Runtime directory does not exist: $OHRuntime"
|
||||
}
|
||||
|
||||
if (-NOT (Test-Path -Path $OHAddons -PathType Container)) {
|
||||
exit PrintAndReturn "Addons directory does not exist: $OHAddons"
|
||||
}
|
||||
|
||||
# Tell the user what we are processing
|
||||
Write-Host -ForegroundColor Yellow "Using $OHConf as conf folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHUserData as userdata folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHRuntime as runtime folder"
|
||||
Write-Host -ForegroundColor Yellow "Using $OHAddons as addons folder"
|
||||
|
||||
# Get current openHAB version
|
||||
$CurrentVersion = GetOpenHABVersion $OHUserData
|
||||
if ($CurrentVersion -eq "") {
|
||||
exit PrintAndReturn "Can't get the current openhab version from $OHDirectory - exiting"
|
||||
}
|
||||
|
||||
# Determine if it's a snapshot
|
||||
$CurrentVersionSnapshot = $False;
|
||||
if ($CurrentVersion.EndsWith("-SNAPSHOT", "CurrentCultureIgnoreCase")) {
|
||||
$CurrentVersionSnapshot = $True;
|
||||
$CurrentVersion = $CurrentVersion.Substring(0, $CurrentVersion.Length - "-SNAPSHOT".Length);
|
||||
}
|
||||
|
||||
# Tell the user our current version
|
||||
if ($CurrentVersionSnapshot) {
|
||||
Write-Host -ForegroundColor Yellow "The current version is $CurrentVersion-SNAPSHOT"
|
||||
} else {
|
||||
Write-Host -ForegroundColor Yellow "The current version is $CurrentVersion"
|
||||
}
|
||||
|
||||
# If the version was not specified,
|
||||
# If the current version is snapshot - make OHVersion the same snapshot
|
||||
# If the current version is stable - make OHVersion the next minor upgrade (current version 2.3.0 would make our OHversion 2.4.0)
|
||||
# If the current version is milestone - make OHVersion the stable version (2.3.0.M6 becomes 2.3.0)
|
||||
if (-Not $OHVersion) {
|
||||
$parts = $CurrentVersion.Split(".")
|
||||
if ($parts.Length -eq 3) {
|
||||
if ($CurrentVersionSnapshot -eq $True) {
|
||||
$OHVersion = $CurrentVersion + "-SNAPSHOT"
|
||||
} else {
|
||||
$OHVersion = $parts[0] + "." + ([int]$parts[1] + 1) + "." + $parts[2]
|
||||
}
|
||||
} elseif ($parts.Length -eq 4) {
|
||||
$OHVersion = $parts[0] + "." + $parts[1] + "." + $parts[2]
|
||||
}
|
||||
else {
|
||||
exit PrintAndReturn "The current version $CurrentVersion was not formatted correctly (d.d.d)"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# If snapshot was defined, add "-snapshot" to the OHVersion if not already present
|
||||
if ($Snapshot -eq $true) {
|
||||
BoxMessage "-SNAPSHOT is deprecated - please put '-snapshot' in OHVersion instead (ex: 2.4.0-snapshot)" Magenta
|
||||
if (-Not $OHVersion.EndsWith("-SNAPSHOT", "CurrentCultureIgnoreCase")) {
|
||||
$OHVersion = $OHVersion + "-SNAPSHOT"
|
||||
}
|
||||
}
|
||||
|
||||
# Split up the OHVersion to validate
|
||||
$parts = $OHVersion.Split(".")
|
||||
|
||||
# If only "2.3" - make "2.3.0"
|
||||
if ($parts.Length -eq 2) {
|
||||
$parts += "0"
|
||||
}
|
||||
|
||||
# Valid versions:
|
||||
# Stable: "2.3.0"
|
||||
# Snapshot: "2.3.0-SNAPSHOT"
|
||||
# Milestone: "2.3.0.M6"
|
||||
if (($parts.Length -lt 3) -or ($parts.Length -gt 4)) {
|
||||
exit PrintAndReturn "The specified OH version $OHVersion was not formatted correctly (d.d.d[.d])"
|
||||
}
|
||||
|
||||
$Snapshot = $False
|
||||
$Milestone = ""
|
||||
if ($parts[2].EndsWith("-SNAPSHOT", "CurrentCultureIgnoreCase")) {
|
||||
$Snapshot = $True
|
||||
$parts[2] = $parts[2].Substring(0, $parts[2].Length - "-SNAPSHOT".Length);
|
||||
} elseif ($parts.Length -eq 4) {
|
||||
$Milestone = $parts[3]
|
||||
}
|
||||
$OHVersion = $parts[0] + "." + $parts[1] + "." + $parts[2]
|
||||
|
||||
# Recreate the name - should be standardized now and is used for messages and downloads
|
||||
if ($Snapshot -eq $True) {
|
||||
$OHVersionName = "$OHVersion-SNAPSHOT"
|
||||
} elseif ($Milestone -ne "") {
|
||||
$OHVersionName = $OHVersion + "." + $Milestone
|
||||
} else {
|
||||
$OHVersionName = $OHVersion
|
||||
}
|
||||
|
||||
# Get the current directory (so we can switch back to it at the end)
|
||||
try {
|
||||
$StartDir = Get-Location -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Can't retrieve the current location - exiting" $_
|
||||
}
|
||||
|
||||
# Set the current directory to our OH root directory
|
||||
Write-Host -ForegroundColor Cyan "Changing location to $OHDirectory"
|
||||
try {
|
||||
Set-Location -Path $OHDirectory
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Could not change location to $OHDirectory - exiting" $_
|
||||
}
|
||||
|
||||
# Setup where our temporary locations will be
|
||||
$TempDir = "$(GetOpenHABTempDirectory)"
|
||||
$TempDistributionZip = "$TempDir\openhab-$OHVersion.zip";
|
||||
$TempDistribution = "$TempDir\update"
|
||||
|
||||
# Create the proper download URLs
|
||||
if ($Snapshot) {
|
||||
$DownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab/target/openhab-$OHVersionName.zip"
|
||||
$AddonsDownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons/target/openhab-addons-$OHVersionName.kar"
|
||||
$LegacyAddonsDownloadLocation="https://ci.openhab.org/job/openHAB-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons-legacy/target/openhab-addons-legacy-$OHVersionName.kar"
|
||||
}
|
||||
elseif ($Milestone -ne "") {
|
||||
$DownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab/$OHVersionName/openhab-$OHVersionName.zip"
|
||||
$AddonsDownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab-addons/$OHVersionName/openhab-addons-$OHVersionName.kar"
|
||||
$LegacyAddonsDownloadLocation="https://openhab.jfrog.io/openhab/libs-milestone-local/org/openhab/distro/openhab-addons-legacy/$OHVersionName/openhab-addons-legacy-$OHVersionName.kar"
|
||||
}
|
||||
else {
|
||||
$DownloadLocation = "https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab%2F$OHVersion%2Fopenhab-$OHVersion.zip"
|
||||
$AddonsDownloadLocation = "https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab-addons%2F$OHVersion%2Fopenhab-addons-$OHVersion.kar"
|
||||
$LegacyAddonsDownloadLocation = "https://bintray.com/openhab/mvn/download_file?file_path=org%2Fopenhab%2Fdistro%2Fopenhab-addons-legacy%2F$OHVersion%2Fopenhab-addons-legacy-$OHVersion.kar"
|
||||
}
|
||||
|
||||
# If we are not in SkipNew (or SkipNew and the temporary distribution file/folders have not been created yet):
|
||||
# 1. Delete and recreate the temporary distribution directory if it exists
|
||||
# 2. Download the distribution to the temp directory
|
||||
# 3. Expand the distribution to the temp directory
|
||||
# 4. Copy the update.ps1/common.psm1 files to the temp distribution if KeepUpdateScript is true (dev purposes only)
|
||||
if (($SkipNew -eq $False) -or
|
||||
(($SkipNew -eq $True) -and -NOT
|
||||
((Test-Path -Path $TempDistributionZip -PathType Leaf) -and (Test-Path -Path $TempDistribution -PathType Container))
|
||||
)
|
||||
) {
|
||||
########### STEP 1 - Delete and recreate the temporary distribution directory if it exists
|
||||
try {
|
||||
DeleteIfExists $TempDir $True
|
||||
}
|
||||
catch {
|
||||
# Do nothing here - probably a file lock issue
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Creating temporary update directory $TempDir"
|
||||
CreateDirectory $TempDir
|
||||
}
|
||||
catch {
|
||||
exit PrintAndReturn "Error creating temporary update directory $TempDir - exiting" $_
|
||||
}
|
||||
|
||||
########### STEP 2 - download the distribution
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Downloading the openHAB $OHVersionName distribution to $TempDistributionZip"
|
||||
DownloadFiles $DownloadLocation $TempDistributionZip
|
||||
}
|
||||
catch {
|
||||
if ([int]$_.Exception.InnerException.Response.StatusCode -eq 404) {
|
||||
exit PrintAndReturn "Download of $OHVersionName failed because it's not a valid version" $_
|
||||
} else {
|
||||
exit PrintAndReturn "Download of $DownloadLocation failed" $_
|
||||
}
|
||||
}
|
||||
|
||||
########### STEP 3 - Expand the archive
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Extracting the archive ($TempDistributionZip) to $TempDistribution"
|
||||
Expand-Archive -Path $TempDistributionZip -DestinationPath $TempDistribution -Force -ErrorAction Stop
|
||||
} catch {
|
||||
exit PrintAndReturn "Unzipping of $TempDistributionZip to $TempDistribution failed." $_
|
||||
}
|
||||
|
||||
########### STEP 4 - Copy the update/common over if we are keeping the update scripts
|
||||
if ($KeepUpdateScript) {
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Keeping commons.psm1 and update.ps1 by copying to $TempDistribution\runtime\bin"
|
||||
Copy-Item -Path "$OHRuntime\bin\common.psm1" -Destination "$TempDistribution\runtime\bin\common.psm1" -Force
|
||||
Copy-Item -Path "$OHRuntime\bin\update.ps1" -Destination "$TempDistribution\runtime\bin\update.ps1" -Force
|
||||
} catch {
|
||||
Write-Error $_
|
||||
Write-Host -ForegroundColor Magenta "Could not copy the common.psm1 and update.ps1 to $TempDistribution\runtime\bin"
|
||||
# Don't bother with AutoConfirm here since this is special debugging logic to begin with
|
||||
$confirmation = Read-Host "Okay to Continue? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling update"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If not SkipNew - check to see if the new distribution has an update.ps1 (which is likely)
|
||||
# and then execute it (exiting with it's result)
|
||||
if ($SkipNew -eq $False) {
|
||||
$newUpdate = Join-Path $TempDistribution "\runtime\bin\update.ps1"
|
||||
|
||||
If (Test-Path $newUpdate) {
|
||||
Write-Host ""
|
||||
BoxMessage "New update.ps1 was found - executing it instead (found in $newUpdate)" Magenta
|
||||
Write-Host ""
|
||||
try {
|
||||
# go back to our original directory so the new update script does it as well
|
||||
Set-Location -Path $StartDir -ErrorAction Continue
|
||||
. $newUpdate
|
||||
exit Update-openHAB -OHDirectory $OHDirectory -OHVersion $OHVersionName -AutoConfirm $AutoConfirm -SkipNew $true -KeepUpdateScript $KeepUpdateScript
|
||||
} catch {
|
||||
exit PrintAndReturn "Execution of new update.ps1 failed - please execute it yourself (found in $newUpdate)" $_
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Do the following questions after the update.ps1 check to make sure this question isn't asked twice!
|
||||
|
||||
# Are we resinstalling the current version (as long as it's not a snapshot)
|
||||
if ($OHVersion -eq $CurrentVersion -and $Snapshot -eq $False) {
|
||||
if ($AutoConfirm) {
|
||||
Write-Host -ForegroundColor Magenta "Current version is equal to specified version ($OHVersionName). ***REINSTALLING*** $OHVersionName instead (rather than upgrading)."
|
||||
} else {
|
||||
Write-Host -ForegroundColor Magenta "Current version is equal to specified version ($OHVersionName). If you continue, you will REINSTALL $OHVersionName rather than upgrade."
|
||||
$confirmation = Read-Host "Okay to Continue? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling update"
|
||||
}
|
||||
}
|
||||
Write-Host -ForegroundColor Yellow "REINSTALLING" -NoNewline -BackgroundColor Blue
|
||||
Write-Host -ForegroundColor Yellow " version $OHVersionName"
|
||||
} else {
|
||||
|
||||
# Are we trying to downgrade the distribution (yikes!)
|
||||
if ((NormalizeVersionNumber $OHVersion) -lt (NormalizeVersionNumber $CurrentVersion)) {
|
||||
# Don't use autoconfirm on a downgrade warning
|
||||
BoxMessage "You are attempting to downgrade from $CurrentVersion to $OHVersionName !!!" Red
|
||||
Write-Host -ForegroundColor Magenta "This script is not meant to downgrade and the results will be unpredictable"
|
||||
$confirmation = Read-Host "Okay to Continue? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling update"
|
||||
}
|
||||
Write-Host -ForegroundColor Yellow "DOWNGRADING" -NoNewline -BackgroundColor Red
|
||||
Write-Host -ForegroundColor Yellow " to version $OHVersionName"
|
||||
} else {
|
||||
Write-Host -ForegroundColor Yellow "Upgrading to version $OHVersionName"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Crete the temporary backup locations to the current distribution
|
||||
$TempBackupDir = "$TempDir\backup-$CurrentVersion"
|
||||
$TempBackupDirHome = $TempBackupDir + "\home"
|
||||
$TempBackupDirRuntime = $TempBackupDir + "\runtime"
|
||||
$TempBackupDirUserData = $TempBackupDir + "\userdata"
|
||||
$TempBackupDirConf = $TempBackupDir + "\conf"
|
||||
|
||||
# Backup the current distribution to those locations
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan "Making a backup of your distribution to $TempBackupDir"
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Creating backup directories in $TempBackupDir"
|
||||
DeleteIfExists $TempBackupDir $True
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Copying directory conf, userdata and runtime to $TempBackupDirConf"
|
||||
Copy-Item -Path $OHConf, $OHUserData, $OHRuntime -Destination $TempBackupDir -Recurse -Force -ErrorAction Stop
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Copying files from $OHDirectory to $TempBackupDirHome"
|
||||
Get-ChildItem $OHDirectory -File -ErrorAction Stop | Copy-Item -Destination $TempBackupDirHome -Force -ErrorAction Stop
|
||||
|
||||
} catch {
|
||||
exit PrintAndReturn "Could not backup existing distribution to $TempBackupDir" $_
|
||||
}
|
||||
|
||||
# Alright - we are ready to being the update process. This will be wrapped in a
|
||||
# try/catch/finally to restore our current distribution on error and to cleanup
|
||||
# the temporary files when finished
|
||||
try {
|
||||
|
||||
# If our update.lst exists, process the notes (ie MSG section) and the PRE section
|
||||
$updateLst = Join-Path $TempDistribution "\runtime\bin\update.lst"
|
||||
|
||||
if (Test-Path $updateLst) {
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan "The script will attempt to update openHAB to version $OHVersionName"
|
||||
Write-Host -ForegroundColor Cyan "Please read the following " -NoNewLine
|
||||
Write-Host -ForegroundColor Green "notes" -NoNewLine
|
||||
Write-Host -ForegroundColor Cyan " and " -NoNewLine
|
||||
Write-Host -ForegroundColor Red "warnings"
|
||||
$NotesFound = $False
|
||||
try {
|
||||
$NotesFound = ProcessVersionChange $updateLst "MSG" "Important notes for version" $CurrentVersion $OHVersion
|
||||
} catch {
|
||||
# PrintAndReturn since there have been no file changes yet
|
||||
exit PrintAndReturn "Could not process 'MSG' of $updateLst" $_
|
||||
}
|
||||
|
||||
if ($NotesFound) {
|
||||
if (-Not $AutoConfirm) {
|
||||
$confirmation = Read-Host "Okay to Continue? [y/N]"
|
||||
if ($confirmation -ne 'y') {
|
||||
exit PrintAndReturn "Cancelling update"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Write-Host -ForegroundColor Blue "No notes found for version $OHVersionName"
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host ""
|
||||
Write-Host -ForegroundColor Cyan "Execute 'PRE' instructions for version $OHVersionName"
|
||||
if (-NOT (ProcessVersionChange $updateLst "PRE" "Performing pre-update tasks for version" $CurrentVersion $OHVersion)) {
|
||||
Write-Host -ForegroundColor Blue "No 'PRE' instructions found for version $OHVersionName"
|
||||
}
|
||||
} catch {
|
||||
return PrintAndThrow "Could not process 'PRE' of $updateLst" $_
|
||||
}
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
|
||||
# Delete current userdata files
|
||||
# Update openHAB
|
||||
# 1. First remove all file in runtime (they will all be replaced)
|
||||
# 2. Remove all the userdata\etc files listed in userdata_sysfiles.lst (they may be replaced)
|
||||
# 3. Remove the cache/tmp directories
|
||||
# 4. Then copy all files from our new distribution WITHOUT overwriting anything
|
||||
# (by removals in 1 & 2 - that means we will replace those)
|
||||
#
|
||||
|
||||
############## STEP 1 - remove runtime
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Deleting current runtime ($OHRuntime)"
|
||||
DeleteIfExists $OHRuntime $True
|
||||
} catch {
|
||||
return PrintAndThrow "Could not delete current runtime ($OHRuntime)" $_
|
||||
}
|
||||
|
||||
############## STEP 2 - remove userdata\etc files in userdata_sysfiles.lst
|
||||
$updateSysFilesLst = "$TempDistribution\runtime\bin\userdata_sysfiles.lst"
|
||||
if (Test-Path $updateSysFilesLst) {
|
||||
Write-Host -ForegroundColor Cyan "Deleting current files in userdata that should not persist"
|
||||
foreach ($FileName in Get-Content $updateSysFilesLst) {
|
||||
$fileToDelete = "$OHUserData\etc\$FileName"
|
||||
try {
|
||||
if (Test-Path -Path $fileToDelete) {
|
||||
DeleteIfExists $fileToDelete
|
||||
Write-Host -ForegroundColor Cyan "Deleted $FileName from $OHUserData\etc"
|
||||
}
|
||||
} catch {
|
||||
Write-Error $_
|
||||
Write-Host "Could not delete $fileToDelete. File is no longer needed and should be manually deleted."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
############## STEP 3 - remove cache/tmp directories
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing $OHUserData\cache"
|
||||
DeleteIfExists "$OHUserData\cache" $True
|
||||
} catch {
|
||||
return PrintAndThrow "Could not delete the $OHUserData\cache directory" $_
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing $OHUserData\tmp"
|
||||
DeleteIfExists "$OHUserData\tmp" $True
|
||||
} catch {
|
||||
return PrintAndThrow "Could not delete the $OHUserData\tmp directory" $_
|
||||
}
|
||||
|
||||
############## STEP 4 - copy files from temporary to distribution WITHOUT replacement
|
||||
Write-Host -ForegroundColor Cyan "Copying $TempDistribution to $OHDirectory without overwriting existing ones"
|
||||
try {
|
||||
Get-ChildItem -Path $TempDistribution -Recurse -ErrorAction Stop | ForEach-Object {
|
||||
$relPath = GetRelativePath $TempDistribution $_.FullName
|
||||
|
||||
if ($relPath.StartsWith(".\addons")) {
|
||||
$localPath = Join-Path $OHAddons $relPath.Substring(".\addons".Length)
|
||||
} elseif ($relPath.StartsWith(".\conf")) {
|
||||
$localPath = Join-Path $OHConf $relPath.Substring(".\conf".Length)
|
||||
} elseif ($relPath.StartsWith(".\userdata")) {
|
||||
$localPath = Join-Path $OHUserData $relPath.Substring(".\userdata".Length)
|
||||
} elseif ($relPath.StartsWith(".\runtime")) {
|
||||
$localPath = Join-Path $OHRuntime $relPath.Substring(".\runtime".Length)
|
||||
} else {
|
||||
$localPath = Join-Path $OHDirectory $relPath
|
||||
}
|
||||
if (-Not (Test-Path $localPath)) {
|
||||
if (Test-Path $localPath -PathType Container) {
|
||||
CreateDirectory $localPath
|
||||
} else {
|
||||
Copy-Item -Path $_.FullName -Destination $localPath -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
return PrintAndThrow "Error occurred copying $TempDistribution to $OHDirectory" $_
|
||||
}
|
||||
|
||||
# If we have an update.lst - process the "POST" section
|
||||
if (Test-Path $updateLst) {
|
||||
Write-Host ""
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Execute 'POST' instructions for version $OHVersionName"
|
||||
if (-NOT (ProcessVersionChange $updateLst "POST" "Performing post-update tasks for version" $CurrentVersion $OHVersion)) {
|
||||
Write-Host -ForegroundColor Blue "No 'POST' instructions found for version $OHVersionName"
|
||||
}
|
||||
} catch {
|
||||
return PrintAndThrow "Could not process 'POST' of $updateLst" $_
|
||||
}
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
|
||||
# If there's an existing addons file, we need to replace it with the correct version.
|
||||
try {
|
||||
$AddonsFile = "$OHAddons\openhab-addons-$OHVersionName.kar"
|
||||
if (Test-Path -Path $AddonsFile) {
|
||||
Write-Host "Found an openHAB addons file, replacing with new version"
|
||||
DeleteIfExists $AddonsFile
|
||||
DownloadFiles $AddonsDownloadLocation "$OHAddons\openhab-addons-$OHVersionName.kar"
|
||||
}
|
||||
} catch {
|
||||
return PrintAndThrow "Could not replace the $AddonsFile" $_
|
||||
}
|
||||
|
||||
|
||||
# Do the same for the legacy addons file.
|
||||
try {
|
||||
$LegacyAddonsFile = "$OHAddons\openhab-addons-legacy-$OHVersionName.kar"
|
||||
if (Test-Path -Path $LegacyAddonsFile) {
|
||||
Write-Host "Found an openHAB legacy addons file, replacing with new version"
|
||||
DeleteIfExists $LegacyAddonsFile
|
||||
DownloadFiles $LegacyAddonsDownloadLocation "$OHAddons\openhab-addons-legacy-$OHVersionName.kar"
|
||||
}
|
||||
} catch {
|
||||
return PrintAndThrow "Could not replace the $LegacyAddonsFile" $_
|
||||
}
|
||||
|
||||
# Hop for joy - we did it!
|
||||
Write-Host -ForegroundColor Green "openHAB updated to version $OHVersionName!"
|
||||
Write-Host -ForegroundColor Green "Run start.bat to launch it."
|
||||
Write-Host -ForegroundColor Green "Check https://www.openhab.org/docs/installation/windows.html"
|
||||
Write-Host -ForegroundColor Green "for instructions on re-installing the Windows Service if desired"
|
||||
}
|
||||
catch {
|
||||
|
||||
# Some issue happened - we need to copy the old distribution back
|
||||
BoxMessage "Restoring your distribution from $TempBackupDir" Yellow
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing existing files in $OHDirectory"
|
||||
Get-ChildItem $OHDirectory -File -ErrorAction SilentlyContinue | Remove-Item -Force -ErrorAction SilentlyContinue
|
||||
Write-Host -ForegroundColor Cyan "Copying backup files from $TempBackupDirHome to $OHDirectory"
|
||||
Get-ChildItem $TempBackupDirHome -file -ErrorAction Stop | Copy-Item -Destination $OHDirectory -Force -ErrorAction Stop
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Removing the directory $OHConf"
|
||||
Remove-Item "$OHConf\*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host -ForegroundColor Cyan "Copying backup directory $TempBackupDirConf to $OHConf"
|
||||
Copy-Item -Path "$TempBackupDirConf\*" -Destination $OHConf -Recurse -Force -ErrorAction Stop
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Removing the directory $OHUserData"
|
||||
Remove-Item "$OHUserData\*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host -ForegroundColor Cyan "Copying backup directory $TempBackupDirUserData to $OHUserData"
|
||||
Copy-Item -Path "$TempBackupDirUserData\*" -Destination $OHUserData -Recurse -Force -ErrorAction Stop
|
||||
|
||||
Write-Host -ForegroundColor Cyan "Removing the directory $OHRuntime"
|
||||
Remove-Item "$OHRuntime\*" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Write-Host -ForegroundColor Cyan "Copying backup directory $TempBackupDirRuntime to $OHRuntime"
|
||||
Copy-Item -Path "$TempBackupDirRuntime\*" -Destination $OHRuntime -Recurse -Force -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host -ForegroundColor Cyan "Restoration was unsuccessful - you may want to restore from $TempBackupDir yourself"
|
||||
Write-Error $_
|
||||
}
|
||||
exit -1
|
||||
}
|
||||
finally {
|
||||
# And we are done...
|
||||
Write-Host ""
|
||||
|
||||
# If our temp backup directory exists - ask if we should remove it
|
||||
# TODO - maybe only do this if an error occurred
|
||||
try {
|
||||
if (Test-Path $TempBackupDir) {
|
||||
if ($AutoConfirm) {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary distribution backup $TempBackupDir"
|
||||
DeleteIfExists $TempBackupDir $True
|
||||
} else {
|
||||
Write-Host -ForegroundColor Cyan "Your prior distribution is in $TempBackupDir"
|
||||
$confirmation = Read-Host "Should it be deleted? [y/N]"
|
||||
if ($confirmation -eq 'y') {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary distribution backup $TempBackupDir"
|
||||
DeleteIfExists $TempBackupDir $True
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $TempBackupDir - delete it manually"
|
||||
}
|
||||
|
||||
try {
|
||||
# If the backup directory doesn't exist - delete the tempdir directory (and it's parent)
|
||||
# (may exist if they answer "N" to the above question)
|
||||
if (-NOT (Test-Path $TempBackupDir)) {
|
||||
try {
|
||||
Write-Host -ForegroundColor Cyan "Removing temporary directory $TempDir"
|
||||
DeleteIfExists $TempDir $True
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $TempDir - delete it manually"
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Write-Host -ForegroundColor Red "Could not delete $parent - delete it manually"
|
||||
}
|
||||
|
||||
# FINALLY - set our location back to where we began
|
||||
Write-Host -ForegroundColor Cyan "Setting location back to $StartDir"
|
||||
Set-Location -Path $StartDir -ErrorAction Continue
|
||||
}
|
||||
}
|
||||
35
runtime/bin/userdata_sysfiles.lst
Normal file
35
runtime/bin/userdata_sysfiles.lst
Normal file
@@ -0,0 +1,35 @@
|
||||
all.policy
|
||||
branding.properties
|
||||
branding-ssh.properties
|
||||
com.eclipsesource.jaxrs.connector.cfg
|
||||
com.eclipsesource.jaxrs.swagger.cfg
|
||||
config.properties
|
||||
custom.properties
|
||||
custom.system.properties
|
||||
distribution.info
|
||||
jmx.acl.org.apache.karaf.bundle.cfg
|
||||
jmx.acl.org.apache.karaf.config.cfg
|
||||
jre.properties
|
||||
org.apache.felix.eventadmin.impl.EventAdmin.cfg
|
||||
org.apache.felix.fileinstall-deploy.cfg
|
||||
org.apache.karaf.command.acl.bundle.cfg
|
||||
org.apache.karaf.command.acl.config.cfg
|
||||
org.apache.karaf.command.acl.feature.cfg
|
||||
org.apache.karaf.command.acl.jaas.cfg
|
||||
org.apache.karaf.command.acl.kar.cfg
|
||||
org.apache.karaf.command.acl.scope_bundle.cfg
|
||||
org.apache.karaf.command.acl.shell.cfg
|
||||
org.apache.karaf.command.acl.system.cfg
|
||||
org.apache.karaf.features.cfg
|
||||
org.apache.karaf.features.repos.cfg
|
||||
org.apache.karaf.jaas.cfg
|
||||
org.apache.karaf.kar.cfg
|
||||
org.apache.karaf.log.cfg
|
||||
org.apache.karaf.shell.cfg
|
||||
org.jupnp.cfg
|
||||
org.ops4j.pax.url.mvn.cfg
|
||||
overrides.properties
|
||||
profile.cfg
|
||||
startup.properties
|
||||
system.properties
|
||||
version.properties
|
||||
199
runtime/etc/jetty.xml
Normal file
199
runtime/etc/jetty.xml
Normal file
@@ -0,0 +1,199 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Jetty Server -->
|
||||
<!-- -->
|
||||
<!-- Documentation of this file format can be found at: -->
|
||||
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
|
||||
<!-- =============================================================== -->
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Set handler Collection Structure -->
|
||||
<!-- =========================================================== -->
|
||||
|
||||
<Get name="handler">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
|
||||
<!-- Add rule in order to take care of the X-Forwarded-Scheme header -->
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.ForwardedSchemeHeaderRule">
|
||||
<Set name="header">X-Forwarded-Scheme</Set>
|
||||
<Set name="headerValue">https</Set> <!-- if this is unset, any value will match against the rule -->
|
||||
<Set name="scheme">https</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.ForwardedSchemeHeaderRule">
|
||||
<Set name="header">X-Forwarded-Scheme</Set>
|
||||
<Set name="headerValue">http</Set> <!-- if this is unset, any value will match against the rule -->
|
||||
<Set name="scheme">http</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
||||
<!-- show the dashboard as default -->
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RedirectRegexRule">
|
||||
<Set name="regex">/$</Set>
|
||||
<Set name="replacement">/start/index</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Get>
|
||||
<Get name="handler">
|
||||
<Call name="addHandler">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.handler.ContextHandler">
|
||||
<Set name="contextPath">/static</Set>
|
||||
<Set name="handler">
|
||||
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
|
||||
<Set name="resourceBase"><SystemProperty name="openhab.conf" />/html</Set>
|
||||
<Set name="directoriesListed">false</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Get>
|
||||
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Set name="secureScheme">https</Set>
|
||||
<Set name="securePort">
|
||||
<Property name="org.osgi.service.http.port.secure" default="8443" />
|
||||
</Set>
|
||||
<Set name="outputBufferSize">32768</Set>
|
||||
<Set name="requestHeaderSize">8192</Set>
|
||||
<Set name="responseHeaderSize">8192</Set>
|
||||
<Set name="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">false</Set>
|
||||
<Set name="headerCacheSize">512</Set>
|
||||
|
||||
<Call name="addCustomizer">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.SecureRequestCustomizer" />
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- extra options -->
|
||||
<!-- =========================================================== -->
|
||||
<Set name="stopAtShutdown">true</Set>
|
||||
<Set name="stopTimeout">1000</Set>
|
||||
<Set name="dumpAfterStart">false</Set>
|
||||
<Set name="dumpBeforeStop">false</Set>
|
||||
|
||||
<New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
|
||||
<Set name="KeyStorePath"><SystemProperty name="jetty.keystore.path" default="/etc/myKeystore" /></Set>
|
||||
<Set name="KeyStorePassword"><SystemProperty name="jetty.ssl.password" default="OBF:1uh81uha1toc1wn31toi1ugg1ugi" /></Set>
|
||||
<Set name="KeyManagerPassword"><SystemProperty name="jetty.ssl.keypassword" default="OBF:1uh81uha1toc1wn31toi1ugg1ugi" /></Set>
|
||||
<Set name="TrustStorePath"><SystemProperty name="jetty.truststore.path" default="/etc/myKeystore" /></Set>
|
||||
<Set name="TrustStorePassword"><SystemProperty name="jetty.ssl.password" default="OBF:1uh81uha1toc1wn31toi1ugg1ugi" /></Set>
|
||||
<Set name="EndpointIdentificationAlgorithm"></Set>
|
||||
<Set name="NeedClientAuth"><SystemProperty name="jetty.ssl.needClientAuth" default="false" /></Set>
|
||||
<Set name="WantClientAuth"><SystemProperty name="jetty.ssl.wantClientAuth" default="false" /></Set>
|
||||
<Set name="ExcludeCipherSuites">
|
||||
<Array type="String">
|
||||
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
|
||||
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
|
||||
<!-- Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers -->
|
||||
<Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item>
|
||||
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA256</Item>
|
||||
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</Item>
|
||||
<Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA</Item>
|
||||
<Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA</Item>
|
||||
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA256</Item>
|
||||
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA256</Item>
|
||||
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item>
|
||||
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<!-- setting required for preventing Poodle attack, see http://stackoverflow.com/questions/26382540/how-to-disable-the-sslv3-protocol-in-jetty-to-prevent-poodle-attack/26388531#26388531 -->
|
||||
<Set name="ExcludeProtocols">
|
||||
<Array type="java.lang.String">
|
||||
<Item>SSLv3</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
|
||||
|
||||
</New>
|
||||
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Add a HTTPS Connector. -->
|
||||
<!-- Configure an o.e.j.server.ServerConnector with connection -->
|
||||
<!-- factories for TLS (aka SSL) and HTTP to provide HTTPS. -->
|
||||
<!-- All accepted TLS connections are wired to a HTTP connection. -->
|
||||
<!-- -->
|
||||
<!-- Consult the javadoc of o.e.j.server.ServerConnector, -->
|
||||
<!-- o.e.j.server.SslConnectionFactory and -->
|
||||
<!-- o.e.j.server.HttpConnectionFactory for all configuration -->
|
||||
<!-- that may be set here. -->
|
||||
<!-- =========================================================== -->
|
||||
|
||||
<Call id="sslConnector" name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector" id="sslConnectorId">
|
||||
<Arg name="server">
|
||||
<Ref refid="Server" />
|
||||
</Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.SslConnectionFactory">
|
||||
<Arg name="next">http/1.1</Arg>
|
||||
<Arg name="sslContextFactory">
|
||||
<Ref refid="sslContextFactory" />
|
||||
</Arg>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config">
|
||||
<Ref refid="httpConfig" />
|
||||
</Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="name">
|
||||
<SystemProperty name="jetty.host" default="0.0.0.0" />:<SystemProperty name="org.osgi.service.http.port.secure" default="8443" />
|
||||
</Set>
|
||||
<Set name="host">
|
||||
<SystemProperty name="jetty.host" />
|
||||
</Set>
|
||||
<Set name="port">
|
||||
<SystemProperty name="org.osgi.service.http.port.secure" default="8443" />
|
||||
</Set>
|
||||
<Set name="idleTimeout">
|
||||
<SystemProperty name="https.timeout" default="30000" />
|
||||
</Set>
|
||||
<Set name="soLingerTime">
|
||||
<SystemProperty name="https.soLingerTime" default="-1" />
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
<Call name="setAttribute">
|
||||
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
|
||||
<Arg>300000</Arg>
|
||||
</Call>
|
||||
</Configure>
|
||||
6
runtime/etc/quartz.properties
Normal file
6
runtime/etc/quartz.properties
Normal file
@@ -0,0 +1,6 @@
|
||||
org.quartz.scheduler.skipUpdateCheck = true
|
||||
org.quartz.scheduler.instanceName = openHAB-job-scheduler
|
||||
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
|
||||
org.quartz.threadPool.threadCount = 2
|
||||
org.quartz.threadPool.threadPriority = 5
|
||||
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
|
||||
27
runtime/lib/README
Normal file
27
runtime/lib/README
Normal file
@@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
This directory is the standard Java classpath directory.
|
||||
Any jar in this folder will be part of the main classloader used to load Karaf.
|
||||
However, in OSGi, classes defined in these jars won't be available to other
|
||||
bundles unless one of the org.osgi.framework.system.packages.extra or
|
||||
org.osgi.framework.bootdelegation properties in the etc/config.properties file
|
||||
is modified to export or delegate the packages.
|
||||
Please refer to the OSGi Core Specification for more information on these
|
||||
properties and the OSGi classloading mechanism.
|
||||
21
runtime/lib/boot/README
Normal file
21
runtime/lib/boot/README
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
Any jar in this folder will be added to the classpath by the JVM and will be
|
||||
available to the Main class. Custom locking libraries can be added here.
|
||||
BIN
runtime/lib/boot/activation-1.1.1.jar
Normal file
BIN
runtime/lib/boot/activation-1.1.1.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/jaxb-api-2.3.0.jar
Normal file
BIN
runtime/lib/boot/jaxb-api-2.3.0.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/jaxb-core-2.2.11.jar
Normal file
BIN
runtime/lib/boot/jaxb-core-2.2.11.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/jaxb-impl-2.2.11.jar
Normal file
BIN
runtime/lib/boot/jaxb-impl-2.2.11.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/org.apache.karaf.diagnostic.boot-4.2.1.jar
Normal file
BIN
runtime/lib/boot/org.apache.karaf.diagnostic.boot-4.2.1.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/org.apache.karaf.jaas.boot-4.2.1.jar
Normal file
BIN
runtime/lib/boot/org.apache.karaf.jaas.boot-4.2.1.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/org.apache.karaf.main-4.2.1.jar
Normal file
BIN
runtime/lib/boot/org.apache.karaf.main-4.2.1.jar
Normal file
Binary file not shown.
BIN
runtime/lib/boot/org.osgi.core-6.0.0.jar
Normal file
BIN
runtime/lib/boot/org.osgi.core-6.0.0.jar
Normal file
Binary file not shown.
23
runtime/lib/endorsed/README
Normal file
23
runtime/lib/endorsed/README
Normal file
@@ -0,0 +1,23 @@
|
||||
################################################################################
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
This directory is the Java endorsed directory.
|
||||
Any jar in this folder will be used to override classes defined by the JVM.
|
||||
For more information, see:
|
||||
http://download.oracle.com/javase/6/docs/technotes/guides/standards/
|
||||
BIN
runtime/lib/endorsed/org.apache.karaf.specs.java.xml-4.2.1.jar
Normal file
BIN
runtime/lib/endorsed/org.apache.karaf.specs.java.xml-4.2.1.jar
Normal file
Binary file not shown.
BIN
runtime/lib/endorsed/org.apache.karaf.specs.locator-4.2.1.jar
Normal file
BIN
runtime/lib/endorsed/org.apache.karaf.specs.locator-4.2.1.jar
Normal file
Binary file not shown.
23
runtime/lib/ext/README
Normal file
23
runtime/lib/ext/README
Normal file
@@ -0,0 +1,23 @@
|
||||
################################################################################
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
This directory is the Java extension directory.
|
||||
Any jar in this folder will be used as a JVM extension.
|
||||
For more information, see
|
||||
http://download.oracle.com/javase/6/docs/technotes/guides/extensions/specs.html
|
||||
16
runtime/services.cfg
Normal file
16
runtime/services.cfg
Normal file
@@ -0,0 +1,16 @@
|
||||
# This file defines required service configurations.
|
||||
# It can be overridden by user specific configurations in conf/services folder.
|
||||
|
||||
org.eclipse.smarthome.folder:items=items
|
||||
org.eclipse.smarthome.folder:sitemaps=sitemap
|
||||
org.eclipse.smarthome.folder:rules=rules
|
||||
org.eclipse.smarthome.folder:scripts=script
|
||||
org.eclipse.smarthome.folder:persistence=persist
|
||||
org.eclipse.smarthome.folder:things=things
|
||||
|
||||
# Configuration of thread pool sizes
|
||||
org.eclipse.smarthome.threadpool:thingHandler=5
|
||||
org.eclipse.smarthome.threadpool:discovery=5
|
||||
org.eclipse.smarthome.threadpool:safeCall=10
|
||||
|
||||
org.eclipse.smarthome.autoupdate:sendOptimisticUpdates=true
|
||||
26
runtime/system/README
Normal file
26
runtime/system/README
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.
|
||||
*/
|
||||
|
||||
This folder is the default repository where OSGi bundles will be loaded
|
||||
from before using other Maven repositories. Bundles are laid out as a
|
||||
Maven 2 repository.
|
||||
|
||||
To change the default repository location, see the karaf.default.repository
|
||||
property in etc/system.properties.
|
||||
|
||||
For the full Maven repository configuration, see the etc/org.ops4j.pax.url.mvn.cfg
|
||||
file.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
runtime/system/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar
Normal file
BIN
runtime/system/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar
Normal file
Binary file not shown.
BIN
runtime/system/com/google/guava/guava/15.0/guava-15.0.jar
Normal file
BIN
runtime/system/com/google/guava/guava/15.0/guava-15.0.jar
Normal file
Binary file not shown.
BIN
runtime/system/com/google/guava/guava/18.0/guava-18.0.jar
Normal file
BIN
runtime/system/com/google/guava/guava/18.0/guava-18.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
runtime/system/commons-io/commons-io/2.2/commons-io-2.2.jar
Normal file
BIN
runtime/system/commons-io/commons-io/2.2/commons-io-2.2.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
runtime/system/commons-net/commons-net/3.3/commons-net-3.3.jar
Normal file
BIN
runtime/system/commons-net/commons-net/3.3/commons-net-3.3.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user