Browse Source

useless sudo in initiate

main
pvincent 3 days ago
parent
commit
6441474965
  1. 2
      doc/bash_tips.md
  2. 4
      doc/index.md
  3. 30
      lib/initiate.bash

2
doc/bash_tips.md

@ -61,3 +61,5 @@ count=$((count+1))
>&2 echo $code >&2 echo $code
fi fi
``` ```
## sudo -E or better source if already root

4
doc/index.md

@ -1,10 +1,10 @@
# Documentation # Documentation
## Initiate
## Initiate again
Rk: useful when timezone has changed or ghostty command has been installed afterwards Rk: useful when timezone has changed or ghostty command has been installed afterwards
`miaou-bash --self-upgrade`
`miaou-bash --self-upgrade` #TODO: does not apply anymore
## debug, use of MIAOU_DEBUG ## debug, use of MIAOU_DEBUG

30
lib/initiate.bash

@ -54,10 +54,10 @@ function fix_users_bashrc {
>&2 echo "WARN: .bashrc for user <$user> has forked from skeleton, please resolve conflict manually from backup: $backup" >&2 echo "WARN: .bashrc for user <$user> has forked from skeleton, please resolve conflict manually from backup: $backup"
fi fi
done done
sudo mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
mv /etc/skel/.bashrc /etc/skel/.bashrc.ORIGINAL
echo 'fixing users .bashrc...DONE' echo 'fixing users .bashrc...DONE'
fi fi
sudo ln -sf "$MIAOU_BASH_DIR"/etc/skel/.bashrc /etc/skel/.bashrc
ln -sf "$MIAOU_BASH_DIR"/etc/skel/.bashrc /etc/skel/.bashrc
} }
function link_etc { function link_etc {
@ -66,23 +66,23 @@ function link_etc {
if [[ -L "$target" ]]; then if [[ -L "$target" ]]; then
if [[ "$(readlink "$target")" != "$source" ]]; then if [[ "$(readlink "$target")" != "$source" ]]; then
sudo ln -sf "$source" "$target"
ln -sf "$source" "$target"
echo "link $target updated" echo "link $target updated"
fi fi
else else
if [[ -f "$target" ]]; then if [[ -f "$target" ]]; then
sudo mv "$target" "$target$BACKUP_SUFFIX"
mv "$target" "$target$BACKUP_SUFFIX"
echo "$target$BACKUP_SUFFIX saved!" echo "$target$BACKUP_SUFFIX saved!"
fi fi
sudo mkdir -p "$(dirname "$target")"
sudo ln -s "$source" "$target"
mkdir -p "$(dirname "$target")"
ln -s "$source" "$target"
echo "link $target created" echo "link $target created"
fi fi
} }
function arch_profile { function arch_profile {
if ! cmp -s /etc/profile "$MIAOU_BASH_DIR"/etc/profile.arch; then if ! cmp -s /etc/profile "$MIAOU_BASH_DIR"/etc/profile.arch; then
sudo cp "$MIAOU_BASH_DIR"/etc/profile.arch /etc/profile
cp "$MIAOU_BASH_DIR"/etc/profile.arch /etc/profile
echo 'arch /etc/profile fixed!' echo 'arch /etc/profile fixed!'
fi fi
} }
@ -195,14 +195,14 @@ function ghostty_global_config {
} }
function link_bin_scripts { function link_bin_scripts {
sudo ln -sf "$MIAOU_BASH_DIR"/bin/miaou-bash /usr/bin/
sudo ln -sf "$MIAOU_BASH_DIR"/bin/pkg_add /usr/bin/
ln -sf "$MIAOU_BASH_DIR"/bin/miaou-bash /usr/bin/
ln -sf "$MIAOU_BASH_DIR"/bin/pkg_add /usr/bin/
} }
function create_sudoers { function create_sudoers {
if [[ ! -f /etc/sudoers.d/miaou-bash ]]; then if [[ ! -f /etc/sudoers.d/miaou-bash ]]; then
echo 'Defaults:%sudo env_keep += "MIAOU_BASH_DIR"' | sudo tee /etc/sudoers.d/miaou-bash >/dev/null
sudo chmod 440 /etc/sudoers.d/miaou-bash
echo 'Defaults:%sudo env_keep += "MIAOU_BASH_DIR"' >/etc/sudoers.d/miaou-bash
chmod 440 /etc/sudoers.d/miaou-bash
fi fi
} }
@ -222,8 +222,8 @@ function launch_hooks {
function apply_mode { function apply_mode {
if [[ "$MIAOU_BASH_MODE" == hosted ]]; then if [[ "$MIAOU_BASH_MODE" == hosted ]]; then
sudo mkdir /var/lib/miaou-bash -p
sudo cp "$MIAOU_BASH_DIR"/.semver_git_tag /var/lib/miaou-bash/semver_current
mkdir /var/lib/miaou-bash -p
cp "$MIAOU_BASH_DIR"/.semver_git_tag /var/lib/miaou-bash/semver_current
fi fi
} }
@ -232,7 +232,7 @@ function fix_locales {
declare -a expected_locales=(en_US.utf8 es_ES.utf8 fr_FR.utf8) declare -a expected_locales=(en_US.utf8 es_ES.utf8 fr_FR.utf8)
declare -A found_locales declare -A found_locales
for locale in "${expected_locales[@]}"; do found_locales["$locale"]=false; done for locale in "${expected_locales[@]}"; do found_locales["$locale"]=false; done
mapfile -t gen_locales < <(sudo locale -a)
mapfile -t gen_locales < <(locale -a)
for locale in "${gen_locales[@]}"; do for locale in "${gen_locales[@]}"; do
if [[ -v found_locales["$locale"] ]]; then found_locales["$locale"]=true; fi if [[ -v found_locales["$locale"] ]]; then found_locales["$locale"]=true; fi
done done
@ -245,7 +245,7 @@ function fix_locales {
fi fi
done done
if [[ "$should_regenerate" == 'true' ]]; then if [[ "$should_regenerate" == 'true' ]]; then
sudo locale-gen
locale-gen
fi fi
} }

Loading…
Cancel
Save