Date: Tue, 05 Apr 2016 16:32:07 -0700 From: Alexis Megas <megas@alum.rpi.edu> To: freebsd-current@freebsd.org Subject: freebsd-update Message-ID: <6KIQMAN4VXT4.V3ETS7TFGAJL3@emweb04oc>
next in thread | raw e-mail | index | archive | help
Hello. Please consider a new clean command in the freebsd-update script. The modified manual and script are located at https://github.com/textbrowser/freebsd-update. Included are two diffs. Sorry for the long e-mail. --- /usr/src/usr.sbin/freebsd-update/freebsd-update.8 2015-08-12 10:21:35.000000000 -0400 +++ ./freebsd-update.8 2016-04-02 15:16:47.780095000 -0400 @@ -119,6 +119,12 @@ .Cm command can be any one of the following: .Bl -tag -width "rollback" +.It Cm clean +Remove the contents of +.Ar workdir . +(default: +.Ar /var/db/freebsd-update/ +). .It Cm fetch Based on the currently installed world and the configuration options set, fetch all available binary updates. --- /usr/src/usr.sbin/freebsd-update/freebsd-update.sh 2015-08-12 10:21:35.000000000 -0400 +++ ./freebsd-update.sh 2016-04-02 15:26:57.990003000 -0400 @@ -53,6 +53,7 @@ --not-running-from-cron -- Run without a tty, for use by automated tools Commands: + clean -- Clean workdir fetch -- Fetch updates from server cron -- Sleep rand(3600) seconds, fetch updates, and send an email if updates were found @@ -474,7 +475,7 @@ ;; # Commands - cron | fetch | upgrade | install | rollback | IDS) + clean | cron | fetch | upgrade | install | rollback | IDS) COMMANDS="${COMMANDS} $1" ;; @@ -559,6 +560,25 @@ mergeconfig } +# Perform sanity checks in preparation of cleaning workdir. +clean_check_params () { + # Check that we are root. All sorts of things won't work otherwise. + if [ `id -u` != 0 ]; then + echo "You must be root to run this." + exit 1 + fi + + # Check that we have a working directory. + _WORKDIR_bad="Directory does not exist or is not writable: " + if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then + echo -n "`basename $0`: " + echo -n "${_WORKDIR_bad}" + echo ${WORKDIR} + exit 1 + fi + cd ${WORKDIR} || exit 1 +} + # Set utility output filtering options, based on ${VERBOSELEVEL} fetch_setup_verboselevel () { case ${VERBOSELEVEL} in @@ -2047,6 +2067,11 @@ echo ${NOWTIME} > lasteolwarn } +# Clean workdir. +clean_run() { + rm -fr * +} + # Do the actual work involved in "fetch" / "cron". fetch_run () { workdir_init || return 1 @@ -3225,6 +3250,12 @@ default_params } +# Clean command. Allow non-interactive use. +cmd_clean () { + clean_check_params + clean_run || exit 1 +} + # Fetch command. Make sure that we're being called # interactively, then run fetch_check_params and fetch_run cmd_fetch () {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6KIQMAN4VXT4.V3ETS7TFGAJL3>