From dd9c6c8b229618a04f77af8240f689945d814ecd Mon Sep 17 00:00:00 2001 From: Olivier Mauras Date: Sat, 11 Mar 2017 22:05:46 +0100 Subject: [PATCH] New package: sv-netmount-0.1 Closes: #5970 [via git-merge-pr] --- srcpkgs/sv-netmount/files/netmount/conf | 11 +++++++++++ srcpkgs/sv-netmount/files/netmount/finish | 15 +++++++++++++++ srcpkgs/sv-netmount/files/netmount/run | 22 ++++++++++++++++++++++ srcpkgs/sv-netmount/template | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 srcpkgs/sv-netmount/files/netmount/conf create mode 100755 srcpkgs/sv-netmount/files/netmount/finish create mode 100755 srcpkgs/sv-netmount/files/netmount/run create mode 100644 srcpkgs/sv-netmount/template diff --git a/srcpkgs/sv-netmount/files/netmount/conf b/srcpkgs/sv-netmount/files/netmount/conf new file mode 100644 index 00000000000..34f6faa8e00 --- /dev/null +++ b/srcpkgs/sv-netmount/files/netmount/conf @@ -0,0 +1,11 @@ +# Configuration for netmount service + +# List of network filesystems +NETWORK_FS="nfs,nfs4,cifs,ceph,glusterfs,fuse.sshfs,davfs" + +# Put here the network manager service name you use +# If you set static ip from rc.local leave commented or empty +#NETWORK_MANAGER=connmand + +# You can specify your gateway or let it be detected +#GATEWAY=192.168.1.1 diff --git a/srcpkgs/sv-netmount/files/netmount/finish b/srcpkgs/sv-netmount/files/netmount/finish new file mode 100755 index 00000000000..86749ee5678 --- /dev/null +++ b/srcpkgs/sv-netmount/files/netmount/finish @@ -0,0 +1,15 @@ +#!/bin/sh +# Load user defined variables +[ -r conf ] && . ./conf + +# Don't do anything if ./run didn't exit properly +[ "$1" -eq 1 ] && exit 0 + +# Simply umount network filesystems +umount -a -f -t $NETWORK_FS > /dev/null 2>&1 +ret=$? +[ $ret -ne 0 ] && umount -a -f -l -t $NETWORK_FS > /dev/null 2>&1 + +umount -a -f -O _netdev > /dev/null 2>&1 +ret=$? +[ $ret -ne 0 ] && umount -a -f -l -O _netdev > /dev/null 2>&1 diff --git a/srcpkgs/sv-netmount/files/netmount/run b/srcpkgs/sv-netmount/files/netmount/run new file mode 100755 index 00000000000..6214befa9c8 --- /dev/null +++ b/srcpkgs/sv-netmount/files/netmount/run @@ -0,0 +1,22 @@ +#!/bin/sh +# Load user defined variables +[ -r conf ] && . ./conf + +# Ensure the network manager is running +[ -z "$NETWORK_MANAGER" ] || sv check "$NETWORK_MANAGER" 2> /dev/null || exit 1 + +# If it's running or not in used - rc.local - discover default gateway +if [ -z "$GATEWAY" ]; then + set -- $(ip route show | grep default) + GATEWAY="$3" +fi + +ping -W 1 -c 1 $GATEWAY > /dev/null 2>&1 || exit 1 + +# Network is up and running so now mount network filesystems from fstab +mount -a -t "$NETWORK_FS" || exit 1 +mount -a -O _netdev || exit 1 + +# Then wait to behave like the service is up +exec chpst -b netmount pause + diff --git a/srcpkgs/sv-netmount/template b/srcpkgs/sv-netmount/template new file mode 100644 index 00000000000..0a062a5d2e2 --- /dev/null +++ b/srcpkgs/sv-netmount/template @@ -0,0 +1,16 @@ +# Template file for 'sv-netmount' +pkgname=sv-netmount +version=0.1 +revision=1 +short_desc="Service to mount/umount network filesystems from fstab" +homepage="http://www.voidlinux.eu/" +maintainer="Olivier Mauras " +license="GPL-2" +build_style="meta" + +depends="runit" + +post_install() { + # runit services + vsv netmount +}