From 8a9985e3a0e84b313f1a6d3ec8a43d0626f1625f Mon Sep 17 00:00:00 2001 From: Marko Korhonen Date: Mon, 10 Oct 2022 11:25:20 +0300 Subject: [PATCH] Setup doas for ubuntu --- config-root.toml | 2 +- home/.config/zsh/04-aliases.zsh | 14 +++++++------- root/etc/doas.conf | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config-root.toml b/config-root.toml index c80c4c55..88115c1f 100644 --- a/config-root.toml +++ b/config-root.toml @@ -216,4 +216,4 @@ include = ["Locale"] include = ["Pacman"] [profiles.mko-laptop] -dotfiles = ["f_cpupower", "f_yubikey_udev.rules"] +dotfiles = ["f_cpupower", "f_yubikey_udev.rules", "f_doas.conf"] diff --git a/home/.config/zsh/04-aliases.zsh b/home/.config/zsh/04-aliases.zsh index ef1c0c97..dea45339 100644 --- a/home/.config/zsh/04-aliases.zsh +++ b/home/.config/zsh/04-aliases.zsh @@ -34,7 +34,7 @@ pi() { {%@@ if distro_id == "arch" @@%} cmd="paru -S $(echo $SELECTED_PKGS)" {%@@ elif distro_id == "ubuntu" @@%} - cmd="sudo apt install $(echo $SELECTED_PKGS)" + cmd="doas apt install $(echo $SELECTED_PKGS)" {%@@ elif distro_id == "termux" @@%} cmd="apt install $(echo $SELECTED_PKGS)" {%@@ endif @@%} @@ -57,7 +57,7 @@ pr() { {%@@ if distro_id == "arch" @@%} cmd="paru -Rns $(echo $SELECTED_PKGS)" {%@@ elif distro_id == "ubuntu" @@%} - cmd="sudo apt remove $(echo $SELECTED_PKGS)" + cmd="doas apt remove $(echo $SELECTED_PKGS)" {%@@ elif distro_id == "termux" @@%} cmd="apt remove $(echo $SELECTED_PKGS)" {%@@ endif @@%} @@ -106,15 +106,15 @@ clean() { DFCMD="df -h / | tail -n 1 | cut -d' ' -f8- | cut -d' ' -f1 | sed 's/[^0-9]*//g'" SPACEBEFORE=$(eval "$DFCMD") trash-empty 10 - sudo journalctl --vacuum-size=500M + doas journalctl --vacuum-size=500M paru -Sc SPACEAFTER=$(eval "$DFCMD") echo "Saved $(calc $SPACEAFTER - $SPACEBEFORE)G of space" } # connect to wireguard -alias startvpn='sudo systemctl start wg-quick@wg0.service' -alias stopvpn='sudo systemctl stop wg-quick@wg0.service' +alias startvpn='doas systemctl start wg-quick@wg0.service' +alias stopvpn='doas systemctl stop wg-quick@wg0.service' # read qrcode from selection qr() { grim -g "$(slurp -d)" - | zbarimg PNG:- } @@ -156,7 +156,7 @@ update() { {%@@ if distro_id == "arch" @@%} paru {%@@ elif distro_id == "ubuntu" @@%} - sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y + doas apt update && doas apt full-upgrade -y && doas apt autoremove -y && doas apt autoclean -y {%@@ elif distro_id == "termux" @@%} pkg update {%@@ endif @@%} @@ -219,7 +219,7 @@ update() { tether() { adb shell su -c "service call connectivity 33 i32 1 s16 me" > /dev/null } # update arch mirrorlist -alias reflect='sudo reflector --latest 200 --threads 8 --verbose --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist' +alias reflect='doas reflector --latest 200 --threads 8 --verbose --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist' # default icon for notify-send alias notify-send='notify-send --icon=alarm' diff --git a/root/etc/doas.conf b/root/etc/doas.conf index 761aa651..cb547a49 100644 --- a/root/etc/doas.conf +++ b/root/etc/doas.conf @@ -1,2 +1,7 @@ +{%@@ if distro_id == "arch" @@%} permit persist :wheel permit nopass :wheel as root cmd pacman +{%@@ else @@%} +permit persist :sudo +permit nopass :sudo as root cmd apt +{%@@ endif @@%}