nixos-rebuild: add explicit option to enable (remote) sudo
Add --use-remote-sudo option. When set, remote commands will be prefixed with 'sudo'. This allows using sudo remotely _without_ having to use sudo locally (when using --build-host/--taget-host).
This commit is contained in:
parent
d7b18bcb37
commit
2c09cfc097
@ -494,6 +494,20 @@
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<option>--use-remote-sudo</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
When set, nixos-rebuild prefixes remote commands that run on
|
||||||
|
the <option>--build-host</option> and <option>--target-host</option>
|
||||||
|
systems with <command>sudo</command>. Setting this option allows
|
||||||
|
deploying as a non-root user.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -90,6 +90,11 @@ while [ "$#" -gt 0 ]; do
|
|||||||
targetHost="$1"
|
targetHost="$1"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
--use-remote-sudo)
|
||||||
|
# note the trailing space
|
||||||
|
maybeSudo="sudo "
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$0: unknown option \`$i'"
|
echo "$0: unknown option \`$i'"
|
||||||
exit 1
|
exit 1
|
||||||
@ -97,10 +102,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$SUDO_USER" ]; then
|
|
||||||
maybeSudo="sudo "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$buildHost" -a -n "$targetHost" ]; then
|
if [ -z "$buildHost" -a -n "$targetHost" ]; then
|
||||||
buildHost="$targetHost"
|
buildHost="$targetHost"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user