# applies it. it would be also be applied after a reboot
$ROOTCMD sysctl --system
+cat >$target/etc/sudoers.d/ianksudoers <<'EOF'
+Defaults timestamp_timeout=1440
+# used in bashrc
+Defaults env_keep += SUDOD
+# always_set_home
+# makes ubuntu be like debian
+# https://unix.stackexchange.com/a/91572
+Defaults always_set_home
+# umask: default setting is to have minimum umask of 0022
+# This lets us have user-specific umasks which are more permissive.
+# I did this for transmission and set it's umask gecos on install,
+# see there for more info.
+Defaults !umask
+# i use sudo in cronjobs, it spams the logs rather uselessly
+# https://stackoverflow.com/questions/14277116/suppress-log-entry-for-single-sudo-commands
+Defaults:root,iank !log_allowed, !pam_session
+# for just the root user, set some env vars
+Defaults>root env_file=/etc/rootsudoenv
+EOF
+
+# remove old config line. can be removed eventually.
f=$target/etc/sudoers
line='iank ALL=(ALL) NOPASSWD: ALL'
-if [[ ! -e $f ]] || ! grep -xF "$line" $f; then
- echo "$line" >> $f
+if grep -qxF "$line" $f; then
+ sed -i "/^$line/d" $f
fi
grep -xFq "$line" $f || tee -a $f <<<"$line"
-# default debian groups (jessie through buster) + adm, sudo, root
-for g in cdrom floppy audio dip video plugdev netdev adm sudo; do
- if getent gropu $g >/dev/null; then
+# default debian groups (jessie through buster) + adm, sudo, root, admin
+for g in cdrom floppy audio dip video plugdev netdev adm sudo admin; do
+ if getent group $g >/dev/null; then
usermod -aG $g iank
fi
done
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
+
x="$(readlink -f "$BASH_SOURCE")"; cd ${x%/*}
usage() {
#/a/opt/openwrt/source/bin/packages/mips_24kc/mypackages/relay_1.0-1_mips_24kc.ipk \
-sudo scp /q/root/shadow/router /p/c/machine_specific/wrt/etc/dropbear/dropbear_rsa_host_key \
+scp /q/root/shadow/router /p/c/machine_specific/wrt/etc/dropbear/dropbear_rsa_host_key \
/p/router-secrets /p/c/machine_specific/wrt/etc/wg.{key,psk} $h:
scp ../openwrtkeyring/usign/* $h:/etc/opkg/keys