Skip to content

Instantly share code, notes, and snippets.

@InvisibleRasta
Created November 17, 2018 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InvisibleRasta/fdb6607510a820628c693d8baad0f52c to your computer and use it in GitHub Desktop.
Save InvisibleRasta/fdb6607510a820628c693d8baad0f52c to your computer and use it in GitHub Desktop.
Gentoo System mantain
#!/bin/bash
# each item you want to prompt about in order
order=(eix revdep world depclean update ecleanpkg ecleandist news)
# prompt string hash for each item
declare -A prompts=(
[eix]="Sync custom package repository and the Gentoo ebuild repository using eix"
[revdep]="Check for and rebuild missing libraries (not normally needed)"
[world]="Update world"
[depclean]="Remove packages no longer needed"
[update]="Manage configuration changes after an emerge completes"
[ecleanpkg]="Cleaning packages"
[ecleandist]="Clean the source files directory by passing the distfiles argument"
[news]="Read news."
)
# the command for each item
eix=(eix-sync)
revdep=(revdep-rebuild -i -- -av)
world=(emerge -avuND @world)
depclean=(emerge -avc)
update=(etc-update)
ecleanpkg=(eclean-pkg)
ecleandist=(eclean-dist)
news=(eselect news read)
for item in "${order[@]}" ; do
prompt="${prompts[$item]}"
# don't try this at home
eval "command=(\"\${$item[@]}\")"
while read -n 1 -r -p "$prompt: (Y/n): " ; do
case "$REPLY" in
# permit the user to hit enter to get the default behavior
[Yy]|'')
# commands are always run with sudo
sudo "${command[@]}"
break
;;
[Nn])
echo
break
;;
*)
printf '\nUnrecognized response "%s". please use Y or N\n' "$REPLY"
;;
esac
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment