Add context information to info and commands

This commit is contained in:
Bruno Tavares 2014-02-20 16:54:29 -03:00
parent d3b46b912d
commit e5ab920485
2 changed files with 12 additions and 6 deletions

View File

@ -7,18 +7,24 @@ kickstart.codename() {
} }
kickstart.info() { kickstart.info() {
echo $@ >&2 [ "$kickstart_context" ] && echo "$kickstart_context >> $@" >&2 || echo "$@" >&2
}
kickstart.context() {
kickstart_context=""
kickstart.info "Setting up $@"
kickstart_context="$@"
} }
kickstart.mute() { kickstart.mute() {
echo "Running \"$@\"" kickstart.info "Running \"$@\""
`$@ >/dev/null 2>&1` `$@ >/dev/null 2>&1`
return $? return $?
} }
kickstart.add_to_profile.d() { kickstart.add_to_profile.d() {
file=$1 file=$1
[ ! -f files/$file ] && echo "File files/$file not found" && exit 1 [ ! -f files/$file ] && kickstart.info "File files/$file not found" && exit 1
cp files/$file /etc/profile.d/$file cp files/$file /etc/profile.d/$file
grep -q $file /etc/zshenv 2>&1 || ( echo "[[ -f /etc/profile.d/$file ]] && source /etc/profile.d/$file" >> /etc/zshenv ) grep -q $file /etc/zshenv 2>&1 || ( echo "[[ -f /etc/profile.d/$file ]] && source /etc/profile.d/$file" >> /etc/zshenv )

View File

@ -6,7 +6,7 @@ elif which yum >/dev/null 2>&1; then
fi fi
if [ "$kickstart_pkg" = '' ]; then if [ "$kickstart_pkg" = '' ]; then
echo 'kickstart only supports apt-get or yum!' >&2 kickstart.info 'kickstart only supports apt-get or yum!'
exit 1 exit 1
fi fi
@ -21,10 +21,10 @@ kickstart.package.installed() {
kickstart.package.install() { kickstart.package.install() {
if kickstart.package.installed "$@"; then if kickstart.package.installed "$@"; then
echo "$@ already installed" kickstart.info "$@ already installed"
return 1 return 1
else else
echo "No packages found matching $@. Installing..." kickstart.info "No packages found matching $@. Installing..."
kickstart.mute "$kickstart_pkg -y install $@" kickstart.mute "$kickstart_pkg -y install $@"
return 0 return 0
fi fi