diff options
author | John-Gee | 2018-08-12 18:27:05 -0700 |
---|---|---|
committer | John-Gee | 2018-08-12 18:27:05 -0700 |
commit | 064e37ba37cee7b00eeec22a0c436268294b9ccf (patch) | |
tree | 7e64b4d74ed5a078be23b7ab71d66823d112ccc8 | |
download | aur-064e37ba37cee7b00eeec22a0c436268294b9ccf.tar.gz |
Reuploaded from aur3
-rw-r--r-- | .SRCINFO | 24 | ||||
-rw-r--r-- | PKGBUILD | 31 | ||||
-rw-r--r-- | autorestartNM | 79 | ||||
-rw-r--r-- | autorestartNM.conf | 3 | ||||
-rw-r--r-- | autorestartNM.install | 23 | ||||
-rw-r--r-- | autorestartNM.service | 6 | ||||
-rw-r--r-- | timer-variable.target | 3 | ||||
-rw-r--r-- | timer-variable.timer | 10 |
8 files changed, 179 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..5025f5e02a3a --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,24 @@ +pkgbase = autorestartnm + pkgdesc = A shell script with systemd services to auto restart NetworkManager when a ping does not go through + pkgver = 0.2 + pkgrel = 3 + url = https://aur.archlinux.org/packages/autorestartnm/ + install = autorestartNM.install + arch = x86_64 + arch = i686 + license = GPL + depends = networkmanager + depends = systemd + source = autorestartNM + source = autorestartNM.conf + source = autorestartNM.service + source = timer-variable.target + source = timer-variable.timer + md5sums = 9d34ecd209c5b2f2f28a45ab97fc24c4 + md5sums = aed75685d41e5fa7044f0778d01a88e2 + md5sums = 9969ba899d8e370b8832c084c444aec0 + md5sums = ee403c5dcd600a66841670941dcc8661 + md5sums = 9e7e89cd1baf1e8ce64bbacd790d0be8 + +pkgname = autorestartnm + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..65b13ed388b0 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,31 @@ +#Maintainer gee + +pkgname=autorestartnm +pkgver=0.2 +pkgrel=3 +pkgdesc="A shell script with systemd services to auto restart NetworkManager when a ping does not go through" +arch=('x86_64' 'i686') +url="https://aur.archlinux.org/packages/autorestartnm/" +license=('GPL') +depends=('networkmanager' 'systemd') +source=('autorestartNM' + 'autorestartNM.conf' + 'autorestartNM.service' + 'timer-variable.target' + 'timer-variable.timer') + +md5sums=('9d34ecd209c5b2f2f28a45ab97fc24c4' + 'aed75685d41e5fa7044f0778d01a88e2' + '9969ba899d8e370b8832c084c444aec0' + 'ee403c5dcd600a66841670941dcc8661' + '9e7e89cd1baf1e8ce64bbacd790d0be8') + +install=autorestartNM.install + +package() { + install -Dm755 autorestartNM ${pkgdir}/usr/bin/autorestartNM + install -Dm644 timer-variable.target ${pkgdir}/etc/systemd/system/timer-variable.target + install -Dm644 timer-variable.timer ${pkgdir}/etc/systemd/system/timer-variable.timer + install -Dm644 autorestartNM.service ${pkgdir}/etc/systemd/system/timer-variable.target.wants/autorestartNM.service + install -Dm644 autorestartNM.conf ${pkgdir}/etc/conf.d/autorestartNM.sample.conf +} diff --git a/autorestartNM b/autorestartNM new file mode 100644 index 000000000000..ee2e803a07f2 --- /dev/null +++ b/autorestartNM @@ -0,0 +1,79 @@ +#!/bin/bash +# +#AutoRestartNM +# +# Copyright (c) 2013 gee +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU Library General Public License as published +# by the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +usage () +{ + echo "AutoRestartNM 0.2 (C) 2013-2015 gee" + echo "Usage: restartNM [ADDRESS] (SLEEPTIME) (RETRIES)" + echo "" + echo "Mandatory argument:" + echo "ADDRESS The address you wish to ping to know if the your network is working as expected" + echo "" + echo "Optional arguments:" + echo "SLEEPTIME The time the script will sleep after failing the ping before retrying to see if it was just a glitch (default: 30s)" + echo "RETRIES The number of times you wish to retry pinging before restarting Network Manager (default: 1)" +} + + +ADDR=$1 +SLEEPTIME=$2 +RETRIES=$3 + +if [ -z "$ADDR" ] +then + usage + exit 1 +fi + +if [ -z "$SLEEPTIME" ] +then + SLEEPTIME=30s +fi + +if [ -z "$RETRIES" ] +then + RETRIES=1 +fi + +LOOPTIMES=0 +SYSNAME="autorestartNM" + + +while [ true ] +do + echo $FIRST + ping -c 4 $ADDR -q + PING=$? + echo $PING + + if [ $PING -eq 0 ] + then + exit 0 + elif [ $LOOPTIMES -ne $RETRIES ] + then + systemd-cat -t "$SYSNAME" echo "First ping failed, going to sleep for $SLEEPTIME." + sleep $SLEEPTIME + let LOOPTIMES++ + else + systemd-cat -t "$SYSNAME" echo "Second ping failed, restarting the NM service." + systemctl restart NetworkManager.service + sleep $SLEEPTIME + exit 0 + fi +done diff --git a/autorestartNM.conf b/autorestartNM.conf new file mode 100644 index 000000000000..9b1e48129aef --- /dev/null +++ b/autorestartNM.conf @@ -0,0 +1,3 @@ +#ADDRESS=192.168.0.1 +#SLEEPTIMES=30s +#RETRIES=1 diff --git a/autorestartNM.install b/autorestartNM.install new file mode 100644 index 000000000000..be89827b7353 --- /dev/null +++ b/autorestartNM.install @@ -0,0 +1,23 @@ +post_install() { + cp /etc/conf.d/autorestartNM.sample.conf /etc/conf.d/autorestartNM.conf + + systemctl daemon-reload + systemctl enable timer-variable.timer + systemctl start timer-variable.timer + + echo '------------------------------------------------------------------------' + echo 'Please edit /etc/conf.d/autorestartNM.conf to your needs.' + echo 'The autorestartNM service will fail till you do so.' + echo '------------------------------------------------------------------------' +} + +post_upgrade() { + systemctl daemon-reload + systemctl restart timer-variable.timer +} + +post_remove() { + systemctl disable timer-variable.timer + systemctl stop timer-variable.timer + systemctl daemon-reload +} diff --git a/autorestartNM.service b/autorestartNM.service new file mode 100644 index 000000000000..e5080a79ff7d --- /dev/null +++ b/autorestartNM.service @@ -0,0 +1,6 @@ +[Unit] +Description=Auto Restart NetworkManager when network is not working + +[Service] +EnvironmentFile=/etc/conf.d/autorestartNM.conf +ExecStart=/usr/bin/autorestartNM $ADDRESS $SLEEPTIMES $RETRIES diff --git a/timer-variable.target b/timer-variable.target new file mode 100644 index 000000000000..8d39eafa1a9f --- /dev/null +++ b/timer-variable.target @@ -0,0 +1,3 @@ +[Unit] +Description=Variable Timer Target +StopWhenUnneeded=yes diff --git a/timer-variable.timer b/timer-variable.timer new file mode 100644 index 000000000000..29b742dc474e --- /dev/null +++ b/timer-variable.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Variable Timer + +[Timer] +OnBootSec=5m +OnUnitActiveSec=5m +Unit=timer-variable.target + +[Install] +WantedBy=basic.target |