forked from openhab/openhab-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-external-resources.sh
executable file
·63 lines (53 loc) · 2.32 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
#!/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)/CNAME" ]; 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
echo_process "Updating the '$1' repo... "
git -C "$resourcefolder/$1" checkout master
git -C "$resourcefolder/$1" pull
else
echo_process "Cloning the '$1' repo... "
mkdir "$resourcefolder/$1"
git clone "https://github.com/$2" "$resourcefolder/$1"
fi
}
pull_or_clone_repo "smarthome" "eclipse/smarthome.git"
pull_or_clone_repo "openhab-distro" "openhab/openhab-distro.git"
pull_or_clone_repo "openhab1-addons" "openhab/openhab1-addons.git"
pull_or_clone_repo "openhab2-addons" "openhab/openhab2-addons.git"
pull_or_clone_repo "openhab-bundles" "openhab/openhab-bundles.git"
pull_or_clone_repo "openhabian" "openhab/openhabian.git"
pull_or_clone_repo "openhab-alexa" "openhab/openhab-alexa.git"
pull_or_clone_repo "openhab-mycroft" "openhab/openhab-mycroft.git"
pull_or_clone_repo "openhab-android" "openhab/openhab-android.git"
echo_process "Updating submodules of the 'openhab-bundles' repo... "
git -C "$resourcefolder/openhab-bundles" submodule update --recursive --remote --init
echo_process "Running Maven Clean Plugin... "
mvn clean
echo_process "Running Maven Package Plugin... "
mvn package