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() {
echo $@ >&2
[ "$kickstart_context" ] && echo "$kickstart_context >> $@" >&2 || echo "$@" >&2
}
kickstart.context() {
kickstart_context=""
kickstart.info "Setting up $@"
kickstart_context="$@"
}
kickstart.mute() {
echo "Running \"$@\""
kickstart.info "Running \"$@\""
`$@ >/dev/null 2>&1`
return $?
}
kickstart.add_to_profile.d() {
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
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
if [ "$kickstart_pkg" = '' ]; then
echo 'kickstart only supports apt-get or yum!' >&2
kickstart.info 'kickstart only supports apt-get or yum!'
exit 1
fi
@ -21,10 +21,10 @@ kickstart.package.installed() {
kickstart.package.install() {
if kickstart.package.installed "$@"; then
echo "$@ already installed"
kickstart.info "$@ already installed"
return 1
else
echo "No packages found matching $@. Installing..."
kickstart.info "No packages found matching $@. Installing..."
kickstart.mute "$kickstart_pkg -y install $@"
return 0
fi