From 84767c0907459f175c62330bdf6351ba8533b90b Mon Sep 17 00:00:00 2001 From: i-c-u-p <96894903+i-c-u-p@users.noreply.github.com> Date: Thu, 19 May 2022 16:23:37 +0000 Subject: [PATCH] sed changes --- scripts/1-setup.sh | 9 ++++----- scripts/3-post-setup.sh | 9 +++------ scripts/startup.sh | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/scripts/1-setup.sh b/scripts/1-setup.sh index a52ea53..641ca38 100755 --- a/scripts/1-setup.sh +++ b/scripts/1-setup.sh @@ -39,14 +39,14 @@ echo " -------------------------------------------------------------------------" TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') if [[ $TOTAL_MEM -gt 8000000 ]]; then -sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf -sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf +sed -i "s/^#\(MAKEFLAGS=\"-j\)2\"/\1$nc\"/; +/^COMPRESSXZ=(xz -c -z -)/s/-c /&-T $nc /" /etc/makepkg.conf fi echo " ------------------------------------------------------------------------- Setup Language to US and set locale -------------------------------------------------------------------------" -sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen +sed -i '/^#en_US.UTF-8 /s/^#//' /etc/locale.gen locale-gen timedatectl --no-ask-password set-timezone ${TIMEZONE} timedatectl --no-ask-password set-ntp 1 @@ -56,8 +56,7 @@ ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime localectl --no-ask-password set-keymap ${KEYMAP} # Add sudo no password rights -sed -i '/^# %wheel ALL=(ALL) NOPASSWD: ALL/s/^# //' /etc/sudoers -sed -i '/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/s/^# //' /etc/sudoers +sed -Ei 's/^# (%wheel ALL=\(ALL(:ALL)?\) NOPASSWD: ALL)/\1/' /etc/sudoers #Add parallel downloading sed -i '/^#ParallelDownloads/s/^#//' /etc/pacman.conf diff --git a/scripts/3-post-setup.sh b/scripts/3-post-setup.sh index 9c5bfec..6703548 100755 --- a/scripts/3-post-setup.sh +++ b/scripts/3-post-setup.sh @@ -143,12 +143,9 @@ echo " ------------------------------------------------------------------------- Cleaning -------------------------------------------------------------------------" -# Remove no password sudo rights -sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# &/' /etc/sudoers -sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# &/' /etc/sudoers -# Add sudo rights -sed -i '/^# %wheel ALL=(ALL) ALL/s/^# //' /etc/sudoers -sed -i '/^# %wheel ALL=(ALL:ALL) ALL/s/^# //' /etc/sudoers +# Remove no password sudo rights, add sudo rights +sed -Ei 's/^%wheel ALL=\(ALL(:ALL)?\) NOPASSWD: ALL/# &/; +s/^# (%wheel ALL=\(ALL(:ALL)?\) ALL)/\1/' /etc/sudoers rm -r $HOME/ArchTitus /home/$USERNAME/ArchTitus diff --git a/scripts/startup.sh b/scripts/startup.sh index 589ff9e..ecea1bf 100755 --- a/scripts/startup.sh +++ b/scripts/startup.sh @@ -24,7 +24,7 @@ fi # @arg $2 string Configuration value. set_option() { if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists - sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists + sed -i "/^${1}.*/d" $CONFIG_FILE # delete option if exists fi echo "${1}=${2}" >>$CONFIG_FILE # add option }