Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to download and install the latest .deb-package from github (https://github.com/elbersb/otr-verwaltung/downloads to be exact).

How can I download the latest package (e.g. *otrverwaltung_0.9.1_all.deb*) automatically with a script from github?

What I have tried so far:

wget -O- -q --no-check-certificate https://github.com/elbersb/otr-verwaltung/downloads | grep -o -l -e 'otrverwaltung_[0-9.]*_all.deb'
#The filename should be saved in a variable OTRPACKAGE
sudo dpkg -i OTRPACKAGE
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted
# Find the URL of the .deb file
url=$(wget -O- -q --no-check-certificate https://github.com/elbersb/otr-verwaltung/downloads |
       sed -ne 's/^.*"\([^"]*otrverwaltung_[^"]*_all\.deb\)".*/\1/p')
case $url in
  http://*|https://*) :;;
  /*) url=https://github.com$url;;
  *) url=https://github.com/elbersb/otr-verwaltung/$url;;
esac
# Create a temporary directory
dir=$(mktemp -dt)
cd "$dir"
# Download the .deb file
wget "$url"
# Install the package
sudo dpkg -i "${url##*/}"
# Clean up
rm "${url##*/}"
cd /
rmdir "$dir"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.