[Midnightbsd-cvs] src [11763] trunk/etc/rc.d: update scripts
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Jul 11 10:15:06 EDT 2018
Revision: 11763
http://svnweb.midnightbsd.org/src/?rev=11763
Author: laffer1
Date: 2018-07-11 10:15:05 -0400 (Wed, 11 Jul 2018)
Log Message:
-----------
update scripts
Modified Paths:
--------------
trunk/etc/rc.d/bgfsck
trunk/etc/rc.d/fsck
trunk/etc/rc.d/ftp-proxy
trunk/etc/rc.d/geli
trunk/etc/rc.d/geli2
trunk/etc/rc.d/gssd
trunk/etc/rc.d/hostapd
trunk/etc/rc.d/hostid_save
Added Paths:
-----------
trunk/etc/rc.d/growfs
Modified: trunk/etc/rc.d/bgfsck
===================================================================
--- trunk/etc/rc.d/bgfsck 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/bgfsck 2018-07-11 14:15:05 UTC (rev 11763)
@@ -12,17 +12,24 @@
name="background-fsck"
rcvar="background_fsck"
start_cmd="bgfsck_start"
+start_precmd="bgfsck_start_precmd"
stop_cmd=":"
-bgfsck_start ()
+bgfsck_start_precmd()
{
- if [ -z "${rc_force}" ]; then
- background_fsck_delay=${background_fsck_delay:=0}
- else
+ if [ $($ID -u) != 0 ]; then
+ err 1 "Must be root."
+ fi
+}
+
+bgfsck_start()
+{
+ : ${background_fsck_delay=0}
+ if [ -n "${rc_force}" ]; then
background_fsck_delay=0
fi
if [ ${background_fsck_delay} -lt 0 ]; then
- echo "Background file system checks delayed indefinitly"
+ warn "Background file system checks delayed indefinitely"
return 0
fi
Modified: trunk/etc/rc.d/fsck
===================================================================
--- trunk/etc/rc.d/fsck 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/fsck 2018-07-11 14:15:05 UTC (rev 11763)
@@ -4,7 +4,7 @@
#
# PROVIDE: fsck
-# REQUIRE: localswap
+# REQUIRE: swap
# KEYWORD: nojail
. /etc/rc.subr
@@ -20,7 +20,7 @@
elif [ ! -r /etc/fstab ]; then
echo "Warning! No /etc/fstab: skipping disk checks."
elif [ "$autoboot" = yes ]; then
- # During fsck ignore SIGQUIT
+ # During fsck ignore SIGQUIT
trap : 3
check_startmsgs && echo "Starting file system checks:"
@@ -42,7 +42,7 @@
echo "Reboot failed; help!"
stop_boot
;;
- 8)
+ 8|16)
if checkyesno fsck_y_enable; then
echo "File system preen failed, trying fsck -y ${fsck_y_flags}"
fsck -y ${fsck_y_flags}
Modified: trunk/etc/rc.d/ftp-proxy
===================================================================
--- trunk/etc/rc.d/ftp-proxy 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/ftp-proxy 2018-07-11 14:15:05 UTC (rev 11763)
@@ -14,4 +14,62 @@
command="/usr/sbin/ftp-proxy"
load_rc_config $name
-run_rc_command "$1"
+
+#
+# manage_pid argument
+# Create or remove a pidfile manually, for daemons that can't be bothered
+# to do it themselves. Takes one argument, which is the argument provided
+# to the rc script. The pidfile will be named /var/run/<$name>.pid,
+# unless $pidfile is defined.
+#
+# The method used to determine the pid is rather hacky; grep ps output to
+# find '$procname|$command', then grep for ${name}_flags. If at all
+# possible, use another method if at all possible, to avoid that dirty-
+# code feeling.
+#
+manage_pid() {
+ local search_string ps_pid
+ case $1 in
+ *start)
+ cmd_string=`basename ${procname:-${command}}`
+ eval flag_string=\"\$${name}_flags\"
+ # Determine the pid.
+ ps_pid=`ps ax -o pid= -o command= | grep $cmd_string | grep -e "$flag_string" | grep -v grep | awk '{ print $1 }'`
+ # Write the pidfile depending on $pidfile status.
+ echo $ps_pid > ${pidfile:-"/var/run/$name.pid"}
+ ;;
+ stop)
+ rm $pidfile
+ ;;
+ esac
+}
+
+# Allow ftp-proxy to start up in two different ways. The typical behavior
+# is to start up one instance of ftp-proxy by setting ftpproxy_enable and
+# ftpproxy_flags. The alternate behavior allows multiple instances of ftp-
+# proxy to be started, allowing different types of proxy behavior. To use the
+# new behavior, a list of instances must be defined, and a list of flags for
+# each instance. For example, if we want to start two instances of ftp-proxy,
+# foo and bar, we would set the following vars.
+# ftpproxy_enable="YES"
+# ftpproxy_instances="foo bar"
+# ftpproxy_foo="<arguments for foo>"
+# ftpproxy_bar="<arguments for bar>"
+#
+# Starting more than one ftp-proxy?
+if [ "$ftpproxy_instances" ] && [ -n "${ftpproxy_instances}" ]; then
+ # Iterate through instance list.
+ for i in $ftpproxy_instances; do
+ #eval ftpproxy_${i}_flags=\$ftpproxy_${i}
+ #eval name=ftpproxy_${i}
+ # Set flags for this instance.
+ eval ftpproxy_flags=\$ftpproxy_${i}
+ # Define a unique pid file name.
+ pidfile="/var/run/ftp-proxy.$i.pid"
+ run_rc_command "$1"
+ manage_pid $1
+ done
+else
+ # Traditional single-instance behavior
+ run_rc_command "$1"
+fi
Modified: trunk/etc/rc.d/geli
===================================================================
--- trunk/etc/rc.d/geli 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/geli 2018-07-11 14:15:05 UTC (rev 11763)
@@ -53,7 +53,7 @@
fi
for provider in ${devices}; do
- provider_=`ltr ${provider} '/' '_'`
+ provider_=`ltr ${provider} '/-' '_'`
eval "flags=\${geli_${provider_}_flags}"
if [ -z "${flags}" ]; then
Modified: trunk/etc/rc.d/geli2
===================================================================
--- trunk/etc/rc.d/geli2 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/geli2 2018-07-11 14:15:05 UTC (rev 11763)
@@ -42,7 +42,7 @@
devices=`geli_make_list`
for provider in ${devices}; do
- provider_=`ltr ${provider} '/' '_'`
+ provider_=`ltr ${provider} '/-' '_'`
eval "autodetach=\${geli_${provider_}_autodetach}"
if [ -z "${autodetach}" ]; then
Added: trunk/etc/rc.d/growfs
===================================================================
--- trunk/etc/rc.d/growfs (rev 0)
+++ trunk/etc/rc.d/growfs 2018-07-11 14:15:05 UTC (rev 11763)
@@ -0,0 +1,97 @@
+#!/bin/sh
+#
+# Copyright 2014 John-Mark Gurney
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $MidnightBSD$
+#
+
+# PROVIDE: growfs
+# BEFORE: sysctl
+# KEYWORD: firstboot
+
+# This allows us to distribute a image
+# and have it work on essentially any size drive.
+#
+# TODO: Figure out where this should really be ordered.
+# I suspect it should go just after fsck but before mountcritlocal.
+#
+
+. /etc/rc.subr
+
+name="growfs"
+start_cmd="growfs_start"
+stop_cmd=":"
+rcvar="growfs_enable"
+
+growfs_start ()
+{
+ echo "Growing root partition to fill device"
+ rootdev=$(df / | tail -n 1 | awk '{ sub("/dev/", "", $1); print $1 }')
+ if [ x"$rootdev" = x"${rootdev%/*}" ]; then
+ # raw device
+ rawdev="$rootdev"
+ else
+ rawdev=$(glabel status | awk '$1 == "'"$rootdev"'" { print $3 }')
+ if [ x"$rawdev" = x"" ]; then
+ echo "Can't figure out device for: $rootdev"
+ return
+ fi
+ fi
+
+ sysctl -b kern.geom.conftxt | awk '
+{
+ lvl=$1
+ device[lvl] = $3
+ type[lvl] = $2
+ idx[lvl] = $7
+ parttype[lvl] = $13
+ if (dev == $3) {
+ for (i = 1; i <= lvl; i++) {
+ # resize
+ if (type[i] == "PART") {
+ pdev = device[i - 1]
+ cmd[i] = "gpart resize -i " idx[i] " " pdev
+ if (parttype[i] == "GPT")
+ cmd[i] = "gpart recover " pdev " ; " cmd[i]
+ } else if (type[i] == "LABEL") {
+ continue
+ } else {
+ print "unhandled type: " type[i]
+ exit 1
+ }
+ }
+ for (i = 1; i <= lvl; i++) {
+ if (cmd[i])
+ system(cmd[i])
+ }
+ exit 0
+ }
+}' dev="$rawdev"
+ gpart commit "$rootdev"
+ growfs -y /dev/"$rootdev"
+}
+
+load_rc_config $name
+run_rc_command "$1"
Property changes on: trunk/etc/rc.d/growfs
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/etc/rc.d/gssd
===================================================================
--- trunk/etc/rc.d/gssd 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/gssd 2018-07-11 14:15:05 UTC (rev 11763)
@@ -9,10 +9,8 @@
. /etc/rc.subr
-name="gssd"
+name=gssd
+rcvar=gssd_enable
load_rc_config $name
-rcvar="gssd_enable"
-command="${gssd:-/usr/sbin/${name}}"
-eval ${name}_flags=\"${gssd_flags}\"
run_rc_command "$1"
Modified: trunk/etc/rc.d/hostapd
===================================================================
--- trunk/etc/rc.d/hostapd 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/hostapd 2018-07-11 14:15:05 UTC (rev 11763)
@@ -10,11 +10,18 @@
. /etc/rc.subr
name="hostapd"
-rcvar="hostapd_enable"
command="/usr/sbin/${name}"
-conf_file="/etc/${name}.conf"
-pidfile="/var/run/${name}.pid"
+ifn="$2"
+if [ -z "$ifn" ]; then
+ rcvar="hostapd_enable"
+ conf_file="/etc/${name}.conf"
+ pidfile="/var/run/${name}.pid"
+else
+ rcvar=
+ conf_file="/etc/${name}-${ifn}.conf"
+ pidfile="/var/run/${name}-${ifn}.pid"
+fi
command_args="-P ${pidfile} -B ${conf_file}"
required_files="${conf_file}"
Modified: trunk/etc/rc.d/hostid_save
===================================================================
--- trunk/etc/rc.d/hostid_save 2018-07-11 14:08:05 UTC (rev 11762)
+++ trunk/etc/rc.d/hostid_save 2018-07-11 14:15:05 UTC (rev 11763)
@@ -4,7 +4,7 @@
#
# PROVIDE: hostid_save
-# REQUIRE: root
+# REQUIRE: hostid root
# KEYWORD: nojail
. /etc/rc.subr
More information about the Midnightbsd-cvs
mailing list