On 09/11/2019 12:52, Klemens Nanni wrote:
On Fri, Nov 08, 2019 at 11:59:20AM +0000, Stuart Henderson wrote:
Given the amount of people which encrypt /home directory on their servers,
it might be useful to be able to define another directory for the sets in
sysupgrade as /home_sysupgrade will not be available in that case.
This (encrypted /home but not boot-loader-assisted FDE) doesn't seem
like it would be all that common a thing to me, but I can think of
other use cases for moving the directory.
I know a similar request was rejected in earlier sysupgrade, but now
that sysupgrade uses /auto_upgrade.conf rather than special code in
install.sub it seems a reasonable change to make.
+.It Fl d Ar directory
+Choose the
Nit: trailing whitespace, otherwise it's OK sthen@
I agree with sthen here, but the diff still misses an update to usage();
SETSDIR values containing spaces will also blow up the script. Not
reachable due to earlier errors, but this is worth noting as we install
`rm -f ${SETSDIR}{${CLEAN}}` into rc.firsttime(8) which is run as root,
so careful with blindly rm(1)'ing user input.
Here a reviewed patch for the whitespace and usage() update.
Maybe we can already commit this while trying to find an elegant
solution to the path with whitespace. Any suggestions into solving the
whitespace issue?
Index: sysupgrade.8
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.10
diff -u -p -r1.10 sysupgrade.8
--- sysupgrade.8 3 Oct 2019 12:43:58 -0000 1.10
+++ sysupgrade.8 12 Nov 2019 07:04:05 -0000
@@ -22,6 +22,7 @@
.Nd upgrade system to the next release or a new snapshot
.Sh SYNOPSIS
.Nm
+.Op Fl d Ar directory
.Op Fl fkn
.Op Fl r | s
.Op Ar installurl
@@ -48,6 +49,12 @@ triggering a one-shot upgrade using the
.Pp
The options are as follows:
.Bl -tag -width Ds
+.It Fl d Ar directory
+Choose the
+.Ar directory
+in which the sets will be downloaded.
+Default is
+.Pa /home/_sysupgrade .
.It Fl f
Force an already applied upgrade.
The default is to upgrade to latest snapshot only if available.
Index: sysupgrade.sh
===================================================================
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.32
diff -u -p -r1.32 sysupgrade.sh
--- sysupgrade.sh 11 Nov 2019 18:26:52 -0000 1.32
+++ sysupgrade.sh 12 Nov 2019 07:04:05 -0000
@@ -25,7 +25,6 @@ umask 0022
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
ARCH=$(uname -m)
-SETSDIR=/home/_sysupgrade
ug_err()
{
@@ -34,7 +33,7 @@ ug_err()
usage()
{
- ug_err "usage: ${0##*/} [-fkn] [-r | -s] [installurl]"
+ ug_err "usage: ${0##*/} [-fkn] [-d directory] [-r | -s] [installurl]"
}
unpriv()
@@ -73,14 +72,16 @@ rmel() {
echo -n "$_c"
}
+SETSDIR=/home/_sysupgrade
RELEASE=false
SNAP=false
FORCE=false
KEEP=false
REBOOT=true
-while getopts fknrs arg; do
+while getopts d:fknrs arg; do
case ${arg} in
+ d) SETSDIR=${OPTARG};;
f) FORCE=true;;
k) KEEP=true;;
n) REBOOT=false;;
@@ -195,7 +196,7 @@ ${KEEP} && > keep
cat <<__EOT >/auto_upgrade.conf
Location of sets = disk
-Pathname to the sets = /home/_sysupgrade/
+Pathname to the sets = ${SETSDIR}
Set name(s) = done
Directory does not contain SHA256.sig. Continue without verification = yes
__EOT
@@ -203,7 +204,7 @@ __EOT
if ! ${KEEP}; then
CLEAN=$(echo SHA256 ${SETS} | sed -e 's/ /,/g')
cat <<__EOT > /etc/rc.firsttime
-rm -f /home/_sysupgrade/{${CLEAN}}
+rm -f ${SETSDIR}/{${CLEAN}}
__EOT
fi