Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to update repo sources in openhab-cli #144

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ def generate_distro_tasks = { dist, gDescription, gPackageName, gInputFile, gVer
fileMode mode
}
}

from("resources/templates") {
into '/usr/share/openhab2/package-templates'
if (pType == 'Rpm') {
exclude '**/*.list'
} else {
exclude '**/*.repo'
}
}

if (dist.contains('addons')){
requires('openhab2')
Expand Down
52 changes: 52 additions & 0 deletions resources/templates/openhab.public.key.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org

mQINBFWz+OYBEACXcmKiL6ix1e4gJIWVoGMF7Hv0VOVKJgIUF/zJYBqk3sXQp/pi
JbIoODhrrIbEK33mqgy1EfzEmDhEurule59hq9HAQpOEz9hVbghhnsB8eXEQ9yJO
Wf8D8UGi2MKmqkvf7//jvdywNaQG/xhLu2xld7MxjuhswfiUWqoRFRpQoKY2QCe9
n92qS0MGGK0B6WgapZZPT6AGyqKYtkCA5qUn7bcoEM2236nXhOAYHJh0o4qJ+cBk
BbSx8KEdrZxKQH50gB//gk/K2s+6CbYYOcJX6z3SLa3fxzlbyH9xQhpumAv/++2v
IIJbJHJicsmCKe/SQ7x5xVh90j6xA3oiYZIG78xWL0xnGCPhFws861dR2iON6CSp
+UKDciEQJH+Ew40la+DcHH7tzHlpZpCC1Jv7VBDkhziPrsscgOtYEwfhsq0Pyfpo
0IsyVDBUyj3Nne1NcKShd6+SYFz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srQ+HBA8AlMTdomJb7KlD8
IAkpERdZazEztc70llVGWtP+aFnr4N0wLuqp998WOrD8ZcSVA4ylHUhY89fpe1Cl
nv9y/mnSuEUzCPSf92pYYKXI0yAj73N7rlCMZUnukQNeFt0bWPRq9mhVSyVinDfK
aJhY3KnWKU/azC/zFN5rcbWSzC/c+rtMU5LibClcQaiTMmk11bOlKbcT+/jAcV3l
0UX3g7NxvxkaumevjCH5u4Gmu8h9C6M0wNLjtyFE1hqWDfRROfQBUqhgSxZ+5B9N
D63qG68pWnUs3Mf6NCoa0I8SgCTOwd3lcng83h8e7+xK+fMjsN/CCJMF6vK+LFle
ebdXE76HYEfqIn9dVKV4Ko1SXZG85ogEd0g=
=Ysxm
-----END PGP PUBLIC KEY BLOCK-----
13 changes: 13 additions & 0 deletions resources/templates/openhab2.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### openHAB 2.X Repositories ###

# This file contains the repos for the different versions of openHAB.
# Remove the hash comment on the deb line to enable a particular repo

## openHAB Stable Repository
#deb https://dl.bintray.com/openhab/apt-repo2 stable main

## openHAB Testing Repository
#deb https://openhab.jfrog.io/openhab/openhab-linuxpkg testing main

## openHAB Snapshot Repository
#deb https://openhab.jfrog.io/openhab/openhab-linuxpkg unstable main
26 changes: 26 additions & 0 deletions resources/templates/openhab2.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
### openHAB 2.X Repositories ###

# This file contains the repos for the different versions of openHAB.
# Set enabled to 1/0 to enable/disable a repo respectively.
# Multiple repos can be enabled at once, so it is recommended to have at least stable enabled.

[openHAB-Stable]
name=openHAB 2.x.x Snapshots
baseurl=https://dl.bintray.com/openhab/rpm-repo2/stable
gpgcheck=1
gpgkey=https://bintray.com/user/downloadSubjectPublicKey?username=openhab
enabled=1

[openHAB-Testing]
name=openHAB 2.x.x Snapshots
baseurl=https://openhab.jfrog.io/openhab/openhab-linuxpkg-rpm/testing
gpgcheck=1
gpgkey=https://bintray.com/user/downloadSubjectPublicKey?username=openhab
enabled=0

[openHAB-Snapshots]
name=openHAB 2.x.x Snapshots
baseurl=https://openhab.jfrog.io/openhab/openhab-linuxpkg-rpm/unstable
gpgcheck=1
gpgkey=https://bintray.com/user/downloadSubjectPublicKey?username=openhab
enabled=0
56 changes: 56 additions & 0 deletions resources/usr/bin/openhab-cli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ usage() {
echo " start [--debug] -- Starts openHAB in the terminal."
echo " status -- Checks to see if openHAB is running."
echo " stop -- Stops any running instance of openHAB."
echo " update-repo [repo] -- Updates the package repository and signature."
echo ""
exit 2
}
Expand Down Expand Up @@ -234,9 +235,64 @@ case "$option" in
fi
;;

"update-repo")
checkRoot "$option"
if [ -z "$1" ]; then
repo="stable"
echo "No repo specified, selecting '$repo' by default..."
else
repo="$1"
fi
case "$repo" in
"stable")
debLineNumber=7
rpmLineNumber=12
;;
"testing")
debLineNumber=10
rpmLineNumber=19
;;
"unstable")
debLineNumber=13
rpmLineNumber=26
;;
*)
echo "Error: Invalid repo name '$repo', valid options are 'stable', 'testing and 'unstable'"
exit 2
;;
esac
echo "This command will tell the package manger to use openHAB's $repo repository."
confirmAction
debSource="$OPENHAB_HOME/package-templates/openhab2.list"
rpmSource="$OPENHAB_HOME/package-templates/openhab2.repo"
pubKey="$OPENHAB_HOME/package-templates/openhab.public.key.asc"
if [ -f "$debSource" ]; then
destination="/etc/apt/sources.list.d/openhab2.list"
echo "Creating ${destination}..."
sed "$debLineNumber"' s/^ *#//' "$debSource" > $destination
echo "Adding Public key..."
gpg --homedir /dev/null --dearmor "$pubKey" || {
echo "Error: Could not add public key, see the openHAB documentation to add it manually."
exit 1
}
mv "$pubKey.gpg" /etc/apt/trusted.gpg.d/openhab2.gpg
elif [ -f "$rpmSource" ]; then
destination="/etc/yum.repos.d/openhab2.repo"
echo "Creating ${destination}..."
sed "$rpmLineNumber"' s/0$/1/' "$rpmSource" > $destination || {
echo "Error: Could not update $destination..."
exit 1
}
else
echo "Error: Could not find source file for package manager."
fi
echo "Success! Please use your package manager's update command get the latest updates."
;;
*)
# Default to showing available commands
echo "Unrecognised command: $option"
usage
;;
esac

exit 0