diff options
author | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
---|---|---|
committer | Olav Vitters <olav@vitters.nl> | 2020-07-30 22:10:35 +0200 |
commit | a5c52c00c16be69e14360222520129d30f76e042 (patch) | |
tree | d44ff9f87b2985ead827c72c55b5aaee23c5dd10 /mageia/usr | |
parent | 817ca842f086f7290f183720539834263c2f1afe (diff) | |
download | initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.gz initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.bz2 initscripts-a5c52c00c16be69e14360222520129d30f76e042.tar.xz initscripts-a5c52c00c16be69e14360222520129d30f76e042.zip |
Align Makefile and tree structure with upstream tree structure
Instead of placing the custom files with the upstream files it seems
clearer to have them mostly separated. This makes it easier to see which
parts are custom and which parts are more or less upstream.
As a result the upstream Makefile only needed minor changes to
accomodate this. The Makefile is NOT bug free, unfortunately it doesn't
always do the right thing, this due to inexperience.
Diffstat (limited to 'mageia/usr')
-rw-r--r-- | mageia/usr/bin/partmon.pl | 64 | ||||
-rw-r--r-- | mageia/usr/lib/lsb/lsb-init-functions | 52 | ||||
-rwxr-xr-x | mageia/usr/sbin/hibernate-cleanup.sh | 121 | ||||
-rw-r--r-- | mageia/usr/sbin/listhome | 7 | ||||
-rwxr-xr-x | mageia/usr/sbin/mdv-network-event | 15 | ||||
-rwxr-xr-x | mageia/usr/sbin/vpn-start | 36 | ||||
-rwxr-xr-x | mageia/usr/sbin/vpn-stop | 18 |
7 files changed, 313 insertions, 0 deletions
diff --git a/mageia/usr/bin/partmon.pl b/mageia/usr/bin/partmon.pl new file mode 100644 index 00000000..d6d297b6 --- /dev/null +++ b/mageia/usr/bin/partmon.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# +# Guillaume Cottenceau (gc@mandriva.com) +# +# Copyright 2002 Mandriva +# +# This software may be freely redistributed under the terms of the GNU +# public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +#use strict; +use MDK::Common; + +my ($verbose); + +sub free_space { + my ($mntpoint) = @_; + my ($blocksize, $size, $avail); + my $buf = ' ' x 20000; + syscall_('statfs', $mntpoint, $buf) or return; + (undef, $blocksize, $size, undef, $avail, undef) = unpack "L!6", $buf; + return $avail * ($blocksize / 1024); +} + +my %partlimits = map { if_(/^(.*\S)(?:\s+?)(\d+)$/, $1 => $2 ) } cat_('/etc/sysconfig/partmon'); + + +my $params = join '', @ARGV; + +$params =~ /-h/ and die "usage: partmon [-v]\n"; +$params =~ /-v/ and $verbose = 1; + + +my $ok = 1; +foreach (cat_('/etc/fstab')) { + /^\s*#/ and next; + my (undef, $mountpoint, undef, undef, undef, undef) = split or next; #- I want at least 6 fields to consider it a valid entry + member($mountpoint, keys %partlimits) or next; + my $free = free_space($mountpoint); + $verbose and print "Free space of <$mountpoint> is <$free>\n"; + if ($free < $partlimits{$mountpoint}) { + print "Warning, free space for <$mountpoint> is only <", free_space($mountpoint), "> (which is inferior to <$partlimits{$mountpoint}>\n"; + $ok = 0; + } +} + +$ok or exit -1; + + +#------------------------------------------------- +#- $Log$ +#- Revision 1.3 2006/05/11 12:45:38 tvignaud +#- more s/Mandrakesoft/mandriva/ +#- +#- Revision 1.2 2002/01/15 13:45:24 chmouel +#- Fix warnings. +#- +#- Revision 1.1 2002/01/15 13:44:15 chmouel +#- Add partition monitor from GC +#- diff --git a/mageia/usr/lib/lsb/lsb-init-functions b/mageia/usr/lib/lsb/lsb-init-functions new file mode 100644 index 00000000..4e11f32e --- /dev/null +++ b/mageia/usr/lib/lsb/lsb-init-functions @@ -0,0 +1,52 @@ +#!/bin/sh +# LSB compliant init functions + +# source standard Mandrake init functions +. /etc/init.d/functions + +start_daemon() { + # Start daemons. + local force= nicelevel= + while [ "$1" != "${1##[-+]}" ]; do + case $1 in + -f) + force="--force" + shift + ;; + -n) + nicelevel=$2 + shift 2 + ;; + esac + done + if [ -z "$1" ]; then + gprintf "%s: Usage: start_daemon [-f] [-n nicelevel] {program} [args]\n" $0 + return 1 + fi + gprintf "Starting %s: " $1 + daemon $force $nicelevel $* + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + touch /var/lock/subsys/$1 + fi + echo + return $RETVAL +} + +# killproc is handled by the normal init.d/functions + +# pidofproc is handled by the normal init.d/functions + +log_success_msg() { + success +} + +log_failure_msg() { + failure +} + +log_warning_msg() { + echo_warning +} + + diff --git a/mageia/usr/sbin/hibernate-cleanup.sh b/mageia/usr/sbin/hibernate-cleanup.sh new file mode 100755 index 00000000..49451859 --- /dev/null +++ b/mageia/usr/sbin/hibernate-cleanup.sh @@ -0,0 +1,121 @@ +#!/bin/sh + +# This script invalidates any stale swsusp and Software Suspend 2 images. It +# searches all swap partitions on your machine, as well as Suspend2's +# filewriter files (by way of the hibernate script telling it where to find +# it). +# +# It should be called on boot, after mounting filesystems, but before enabling +# swap or clearing out /var/run. Copy this into /etc/init.d/ (or the appropriate +# place on your system), then add a symlink at the appropriate point on boot. +# On a Debian system, you would do this: +# update-rc.d hibernate-cleanup.sh start 31 S . +# +# On other SysV-based systems, you would do something like: +# ln -s ../init.d/hibernate-cleanup.sh /etc/rcS.d/S31hibernate-cleanup.sh + +HIBERNATE_FILEWRITER_TRAIL="/var/run/suspend2_filewriter_image_exists" + +get_part_label() { + local ID_FS_LABEL + + eval "$(vol_id -x $1 2> /dev/null)" + echo "$ID_FS_LABEL" +} + +get_part_uuid() { + local ID_FS_UUID + + eval "$(vol_id -x $1 2> /dev/null)" + echo "$ID_FS_UUID" +} + +get_swap_id() { + local line + fdisk -l 2>/dev/null | while read line; do + case "$line" in + /*Linux\ [sS]wap*) echo "${line%% *}" + esac + done +} + +clear_swap() { + local where wason label uuid + where=$1 + wason= + test x"$2" = x || label="-L $2" + test x"$3" = x || uuid="-U $3" + swapoff $where 2>/dev/null && wason=yes + mkswap $where $label $uuid > /dev/null || echo -n " (failed: $?)" + [ -n "$wason" ] && swapon $where +} + +check_swap_sig() { + local part="$(get_swap_id)" + local where what type rest p c dev label + while read where what type rest ; do + test "$type" = "swap" || continue + c=continue + dev= + label= + for p in $part ; do + case "$where" in + LABEL=* ) + test x"$(get_part_label $p)" = x"${where#LABEL=}" && { + c=: + dev=$p + label=${where#LABEL=} + } + ;; + UUID=* ) + test x"$(get_part_uuid $p)" = x"${where#UUID=}" && { + c=: + dev=$p + uuid=${where#UUID=} + } + ;; + * ) + test "$p" = "$where" && { + c=: + dev=$p + } + ;; + esac + done + $c + case "$(dd if=$dev bs=1 count=6 skip=4086 2>/dev/null)" in + ULSUSP|S1SUSP|S2SUSP|pmdisk|[zZ]*) + echo -n "$dev" + clear_swap $dev "$label" "$uuid" + echo -n ", " + esac + done < /etc/fstab +} + +check_filewriter_sig() { + local target + [ -f "$HIBERNATE_FILEWRITER_TRAIL" ] || return + read target < $HIBERNATE_FILEWRITER_TRAIL + [ -f "$target" ] || return + case "`dd \"if=$target\" bs=8 count=1 2>/dev/null`" in + HaveImag) + /bin/echo -ne "Suspend2\n\0\0" | dd "of=$target" bs=11 count=1 conv=notrunc 2>/dev/null + echo -n "$target, " + rm -f $HIBERNATE_FILEWRITER_TRAIL + esac +} + +case "$1" in +start) + echo -n "Invalidating stale software suspend images... " + check_swap_sig + check_filewriter_sig + echo "done." + ;; +stop|restart|force-reload) + ;; +*) + echo "Usage: /etc/init.d/hibernate {start|stop|restart|force-reload}" +esac + +exit 0 diff --git a/mageia/usr/sbin/listhome b/mageia/usr/sbin/listhome new file mode 100644 index 00000000..733dbe08 --- /dev/null +++ b/mageia/usr/sbin/listhome @@ -0,0 +1,7 @@ +#!/bin/sh +# Chmouel Boudjnah <chmouel@mandriva.com> +# Description: List the home greather than 501 should be unusefull now, but +# here for backward compatibilities + +LC_ALL=C LANG=C LANGUAGE=C \ +perl -n -e 'while(my @list=getpwent){print $list[-2], "\n" unless $list[2] <= 999}' < /etc/passwd diff --git a/mageia/usr/sbin/mdv-network-event b/mageia/usr/sbin/mdv-network-event new file mode 100755 index 00000000..705361b7 --- /dev/null +++ b/mageia/usr/sbin/mdv-network-event @@ -0,0 +1,15 @@ +#!/bin/sh +# usage "mdv-network-event <event> <interface> + +EVENT=$1 +INTERFACE=$2 +if [ -z "$EVENT" ] || [ -z "$INTERFACE" ] || [ ! -x /usr/bin/dbus-send ]; then + exit +fi + +/usr/bin/dbus-send --system --type=signal \ + /org/mageia/network/status \ + org.mageia.network.status \ + "string:$EVENT" \ + "string:$INTERFACE" \ + 2>/dev/null diff --git a/mageia/usr/sbin/vpn-start b/mageia/usr/sbin/vpn-start new file mode 100755 index 00000000..49a02cf1 --- /dev/null +++ b/mageia/usr/sbin/vpn-start @@ -0,0 +1,36 @@ +#!/bin/sh + +TYPE=$1 +NAME=$2 +shift 2 +if [ -z "$TYPE" ] || [ -z "$NAME" ]; then + echo "usage: $0: <VPN type> <VPN name> [parameters]" +fi + +DIR=/etc/sysconfig/network-scripts/vpn.d/"$TYPE" +CONFIG="$DIR"/"$NAME".conf +PID=/var/run/"$TYPE"-"$NAME".pid + +. /etc/init.d/functions + +if pidofproc "$PID" >/dev/null; then + gprintf "Connection is already started, please stop it first.\n" + exit 1 +fi + +case $TYPE in + pptp) + gprintf "No implementation for connection type $TYPE yet.\n"; + exit 1 + ;; + openvpn) + action "Starting VPN connection: " openvpn --user openvpn --group openvpn --daemon --writepid $PID --config $CONFIG --cd $DIR $* + ;; + vpnc) + action "Starting VPN connection: " /usr/sbin/vpnc $CONFIG --pid-file $PID $* + ;; + *) + gprintf "Connection type $TYPE is not supported.\n"; + exit 1 + ;; +esac diff --git a/mageia/usr/sbin/vpn-stop b/mageia/usr/sbin/vpn-stop new file mode 100755 index 00000000..048c909f --- /dev/null +++ b/mageia/usr/sbin/vpn-stop @@ -0,0 +1,18 @@ +#!/bin/sh + +TYPE=$1 +NAME=$2 +if [ -z "$TYPE" ] || [ -z "$NAME" ]; then + echo "usage: $0: <VPN type> <VPN name>" +fi + +PID=/var/run/"$TYPE"-"$NAME".pid + +. /etc/init.d/functions +if [ -e "$PID" ]; then + gprintf "Stopping VPN connection: " + killproc -p "$PID" + echo +else + gprintf "Connection isn't started.\n" +fi |