1*d670a8f7SMike Karels#!/bin/sh 2*d670a8f7SMike Karels# 3*d670a8f7SMike Karels# Copyright 2022 Michael J. Karels 4*d670a8f7SMike Karels# 5*d670a8f7SMike Karels# Redistribution and use in source and binary forms, with or without 6*d670a8f7SMike Karels# modification, are permitted provided that the following conditions 7*d670a8f7SMike Karels# are met: 8*d670a8f7SMike Karels# 1. Redistributions of source code must retain the above copyright 9*d670a8f7SMike Karels# notice, this list of conditions and the following disclaimer. 10*d670a8f7SMike Karels# 2. Redistributions in binary form must reproduce the above copyright 11*d670a8f7SMike Karels# notice, this list of conditions and the following disclaimer in the 12*d670a8f7SMike Karels# documentation and/or other materials provided with the distribution. 13*d670a8f7SMike Karels# 14*d670a8f7SMike Karels# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*d670a8f7SMike Karels# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*d670a8f7SMike Karels# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*d670a8f7SMike Karels# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*d670a8f7SMike Karels# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*d670a8f7SMike Karels# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*d670a8f7SMike Karels# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*d670a8f7SMike Karels# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*d670a8f7SMike Karels# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*d670a8f7SMike Karels# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*d670a8f7SMike Karels# SUCH DAMAGE. 25*d670a8f7SMike Karels# 26*d670a8f7SMike Karels# $FreeBSD$ 27*d670a8f7SMike Karels# 28*d670a8f7SMike Karels 29*d670a8f7SMike Karels# PROVIDE: growfs_fstab 30*d670a8f7SMike Karels# REQUIRE: growfs root 31*d670a8f7SMike Karels# KEYWORD: firstboot 32*d670a8f7SMike Karels 33*d670a8f7SMike Karels# If the growfs script added a swap partition, then add a swap entry 34*d670a8f7SMike Karels# to /etc/fstab if none exists, and add as dumpdev. 35*d670a8f7SMike Karels 36*d670a8f7SMike Karels. /etc/rc.subr 37*d670a8f7SMike Karels 38*d670a8f7SMike Karelsname="growfs_fstab" 39*d670a8f7SMike Karelsdesc="Add new swap partition to /etc/fstab" 40*d670a8f7SMike Karelsstart_cmd="growfs_fstab_start" 41*d670a8f7SMike Karelsstop_cmd=":" 42*d670a8f7SMike Karelsrcvar="growfs_enable" 43*d670a8f7SMike Karels 44*d670a8f7SMike Karelsgrowfs_fstab_start() 45*d670a8f7SMike Karels{ 46*d670a8f7SMike Karels if kenv -q growfs_swap_pdev >/dev/null 47*d670a8f7SMike Karels then 48*d670a8f7SMike Karels if awk ' 49*d670a8f7SMike Karels /^#/ { next } 50*d670a8f7SMike Karels $3 == "swap" { exit 1 } 51*d670a8f7SMike Karels ' < /etc/fstab 52*d670a8f7SMike Karels then 53*d670a8f7SMike Karels printf "/dev/label/growfs_swap\tnone\t\tswap\tsw\t\t0\t0\n" >>/etc/fstab 54*d670a8f7SMike Karels 55*d670a8f7SMike Karels case "$dumpdev" in 56*d670a8f7SMike Karels [Aa][Uu][Tt][Oo]) 57*d670a8f7SMike Karels dumpon $dumpon_flags /dev/label/growfs_swap 58*d670a8f7SMike Karels ;; 59*d670a8f7SMike Karels *) 60*d670a8f7SMike Karels ;; 61*d670a8f7SMike Karels esac 62*d670a8f7SMike Karels fi 63*d670a8f7SMike Karels fi 64*d670a8f7SMike Karels} 65*d670a8f7SMike Karels 66*d670a8f7SMike Karelsload_rc_config $name 67*d670a8f7SMike Karelsrun_rc_command "$1" 68