From 86bf7a88b80b72d4cff7c42c8de30c379488270e Mon Sep 17 00:00:00 2001 From: Kirill Zaitsev Date: Tue, 14 Oct 2014 13:16:20 +0400 Subject: [PATCH] Fix packages install without bc --- packaging/scripts/postinst.deb | 22 +++++++--------------- packaging/scripts/postrm.deb | 6 +++--- packaging/scripts/prerm.deb | 8 ++++---- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/packaging/scripts/postinst.deb b/packaging/scripts/postinst.deb index 167c54e3..8d0031eb 100644 --- a/packaging/scripts/postinst.deb +++ b/packaging/scripts/postinst.deb @@ -21,18 +21,18 @@ dist() { } version() { - lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' + lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' | awk -F. '{ print $1 }' } upstart() { if [ -d /etc/init ]; then + echo "Your system $(dist) $(version): using upstart to control Drone" if [ -f /usr/local/bin/droned ]; then if pidof /usr/local/bin/droned >/dev/null; then initctl stop drone || : fi fi - echo "You have $(dist) $(version): using upstart to control Drone" cp -r /usr/share/drone/init/drone.conf /etc/init/drone.conf initctl start drone || : else @@ -44,17 +44,13 @@ upstart() { systemd() { if which systemctl > /dev/null; then - echo "Your system $(dist) $(version): using systemd to control Drone" cp /usr/share/drone/systemd/drone.service /lib/systemd/system/drone.service systemctl daemon-reload || : - if [ "$1" = 1 ] ; then - # first time install + if [ "$1" = "configure" ] ; then + echo "Your system $(dist) $(version): using systemd to control Drone" systemctl enable drone || : - systemctl start drone || : - else - echo "Upgrading drone" - systemctl restart drone + systemctl restart drone || : fi else echo "Couldn't find systemd to control Drone, cannot proceed." @@ -63,20 +59,16 @@ systemd() { fi } -validate_ver() { - echo "$(version) < $1" | bc -} - case "$(dist)" in debian) - if [ $(validate_ver "8.0") -eq 1 ]; then + if [ "$(version)" -lt "8" ]; then upstart else systemd $1 fi ;; ubuntu) - if [ $(validate_ver "14.10") -eq 1 ]; then + if [ "$(version)" -lt "15" ]; then upstart else systemd $1 diff --git a/packaging/scripts/postrm.deb b/packaging/scripts/postrm.deb index bd84cdbc..9808fdce 100644 --- a/packaging/scripts/postrm.deb +++ b/packaging/scripts/postrm.deb @@ -7,7 +7,7 @@ dist() { } version() { - lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' + lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' | awk -F. '{ print $1 }' } upstart() { @@ -24,14 +24,14 @@ validate_ver() { case "$(dist)" in debian) - if [ $(validate_ver "8.0") -eq 1 ]; then + if [ "$(version)" -lt "8" ]; then upstart else systemd fi ;; ubuntu) - if [ $(validate_ver "14.10") -eq 1 ]; then + if [ "$(version)" -lt "15" ]; then upstart else systemd diff --git a/packaging/scripts/prerm.deb b/packaging/scripts/prerm.deb index ccfe848a..78a5d99e 100644 --- a/packaging/scripts/prerm.deb +++ b/packaging/scripts/prerm.deb @@ -6,7 +6,7 @@ dist() { } version() { - lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' + lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' | awk -F. '{ print $1 }' } echo Stopping drone @@ -16,7 +16,7 @@ upstart() { } systemd() { - if [ "$1" -eq 0 ] ; then + if [ $1 = "remove" ] ; then systemctl --no-reload disable drone || : systemctl stop drone || : fi @@ -28,14 +28,14 @@ validate_ver() { case "$(dist)" in debian) - if [ $(validate_ver "8.0") -eq 1 ]; then + if [ "$(version)" -lt "8" ]; then upstart else systemd $1 fi ;; ubuntu) - if [ $(validate_ver "14.10") -eq 1 ]; then + if [ "$(version)" -lt "15" ]; then upstart else systemd $1