Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.