Add support to brew

This commit is contained in:
Bruno Tavares 2014-02-21 15:10:49 -03:00
parent 71c881ee96
commit dcebd553ab
3 changed files with 24 additions and 18 deletions

View File

@ -1,5 +1,6 @@
kickstart.os() {
( uname -a | grep -q Ubuntu ) && echo "Ubuntu"
( uname -a | grep -q Darwin ) && echo "Mac"
}
kickstart.codename() {

View File

@ -1,22 +1,15 @@
# Set $kickstart_pkg to "apt-get" or "yum", or abort.
if which apt-get >/dev/null 2>&1; then
export kickstart_pkg=apt-get
elif which yum >/dev/null 2>&1; then
export kickstart_pkg=yum
fi
if [ "$kickstart_pkg" = '' ]; then
kickstart.info 'kickstart only supports apt-get or yum!'
exit 1
fi
kickstart.package.manager() {
kickstart.command_exists apt-get && echo "apt-get" && return 0
kickstart.command_exists yum && echo "yum" && return 0
kickstart.command_exists brew && echo "brew" && return 0
kickstart.info "kickstart supports apt-get, yum or brew" && exit 1
}
kickstart.package.installed() {
if [ "$kickstart_pkg" = 'apt-get' ]; then
dpkg -s $@ >/dev/null 2>&1
elif [ "$kickstart_pkg" = 'yum' ]; then
rpm -qa | grep $@ >/dev/null
fi
return $?
local pkg_manager=`kickstart.package.manager`
[ $pkg_manager = 'apt-get' ] && dpkg -s $@ >/dev/null 2>&1 && return $?
[ $pkg_manager = 'yum' ] && rpm -qa | grep -q $@ && return $?
[ $pkg_manager = 'brew' ] && ! $(brew info $@ | grep -q "Not installed") && return $?
}
kickstart.package.install() {
@ -25,7 +18,15 @@ kickstart.package.install() {
return 1
else
kickstart.info "No packages found matching $@. Installing..."
kickstart.mute "$kickstart_pkg -y install $@"
kickstart.mute "`kickstart.package.manager` install -y $@"
return 0
fi
}
kickstart.package.update() {
kickstart.mute "`kickstart.package.manager` update -y"
}
kickstart.package.upgrade() {
kickstart.mute "`kickstart.package.manager` upgrade -y"
}

View File

@ -1,16 +1,20 @@
kickstart.service.enable() {
[ `which enable` ] && enable $1
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
}
kickstart.service.disable() {
[ `which disable` ] && disable $1
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
}
kickstart.service.start() {
[ `which start` ] && start $1
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
}
kickstart.service.stop() {
[ `which stop` ] && stop $1
kickstart.os.is "Mac" && kickstart.info "Mac services not supported yet"
}
kickstart.service.restart() {