-
-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathupdate-external-resources.sh
executable file
·74 lines (63 loc) · 3.38 KB
/
update-external-resources.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
set -e
# openHAB documentation
# This script is used to retrieve external resources and integrate them in the documentation (e.g. Binding READMEs).
# If you are here to help improve the documentation content, you can ignore this file.
# Helper functions
timestamp() { date +"%F_%T_%Z"; }
echo_process() { echo -e "\\e[1;94m$(timestamp)\\e[0m $*"; }
# Log everything to a file
#exec &> >(tee -a "update-docs-$(date +%Y-%m-%d_%H%M%S).log")
# Switch to the script folder
cd "$(dirname $0)" || exit 1
if [ ! -f "$(dirname $0)/LICENSE" ]; then
echo "I'm confused and don't know where I am. Exiting." >&2
exit 1
fi
resourcefolder=$(dirname "$0")/.external-resources
mkdir -p "$resourcefolder"
echo -e "# About\\n\\nUsed to temporarily store repository clones from related openHAB projects for 'update-external-resources.sh'." > "$resourcefolder/README.md"
# Prerequisites
if ! command -v git &>/dev/null || ! command -v mvn &>/dev/null; then
echo "The git or mvn command were not found on the system. Please install. Exiting."
exit 1
fi
echo_process "Updating the base openhab-docs repo... (skipping)"
#git pull
# Parameters: $1=name, $2=GitHub project
pull_or_clone_repo() {
if [ -d "$resourcefolder/$1" ]; then
# Make sure to get all available branches in case of future script adaptions
git -C "$resourcefolder/$1" fetch origin -v
echo_process "Updating the '$1' repo... "
git -C "$resourcefolder/$1" checkout $3
git -C "$resourcefolder/$1" pull
else
echo_process "Cloning the '$1' repo... "
mkdir "$resourcefolder/$1"
git clone --depth 1 --branch $3 "https://github.com/$2" "$resourcefolder/$1"
fi
}
# Pull or clone the repo with a specified branch into the given folder
pull_or_clone_repo "openhab-distro" "openhab/openhab-distro.git" main
pull_or_clone_repo "openhab-addons" "openhab/openhab-addons.git" main
pull_or_clone_repo "openhabian" "openhab/openhabian.git" main
pull_or_clone_repo "openhab-alexa" "openhab/openhab-alexa.git" main
pull_or_clone_repo "openhab-mycroft" "openhab/openhab-mycroft.git" main
pull_or_clone_repo "openhab-android" "openhab/openhab-android.git" main
pull_or_clone_repo "openhab-google-assistant" "openhab/openhab-google-assistant.git" main
pull_or_clone_repo "openhab-webui" "openhab/openhab-webui.git" main
pull_or_clone_repo "openhab-addons/bundles/org.openhab.binding.zigbee" "openhab/org.openhab.binding.zigbee.git" main
pull_or_clone_repo "openhab-addons/bundles/org.openhab.binding.zwave" "openhab/org.openhab.binding.zwave.git" main
# copy zigbee readme to where the groovy script will see it
cp $resourcefolder/openhab-addons/bundles/org.openhab.binding.zigbee/org.openhab.binding.zigbee/README.md $resourcefolder/openhab-addons/bundles/org.openhab.binding.zigbee/
#rm -rf openhab-addons/bundles/org.openhab.binding.zwave
#mv org.openhab.binding.zigbee openhab-addons/bundles
#mv org.openhab.binding.zwave openhab-addons/bundles
echo_process "Fetching feature.xml file from the snapshot repository..."
# Getting all possibly relevant xml files
wget -r -l 2 -npdH -A '*features.xml' -P "$resourcefolder/jfrog-files" "https://openhab.jfrog.io/openhab/libs-snapshot/org/openhab/distro/openhab-addons/"
# Copy the latest feature file into the finally used feature.xml
cp `ls .external-resources/jfrog-files/openhab-addons-*-features.xml | sort | tail -1` .external-resources/jfrog-files/feature.xml
echo_process "Running Maven.... "
mvn clean