#!/bin/bash # SVC - SV Commander - frontend for the sv command ############################################################################################### ## Copyright (c) 2015, Justin Moore ## ## Permission to use, copy, modify, and/or distribute this software ## for any purpose with or without fee is hereby granted, ## provided that the above copyright notice and this permission notice appear in all copies. ## ## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ## WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ## AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, ## OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ############################################################################################## RED='\033[0;31m' LRED="\033[1;31m" BLUE="\033[0;34m" LBLUE="\033[1;34m" GREEN="\033[0;32m" LGREEN="\033[1;32m" YELLOW="\033[1;33m" CYAN="\033[0;36m" LCYAN="\033[1;36m" PURPLE="\033[0;35m" LPURPLE="\033[1;35m" BWHITE="\e[1m" NC='\033[0m' # No Color help(){ printf """ svc - Service Commander - frontend for the sv command Usage: svc link | unlink | linked | list | up | start | restart | stop For detailed help, see the commands below: start Start a linked service restart Restart a linked service stop Stop a linked service link Symlink directory/file to /var/service unlink Remove symlink from linked View symlink paths of all services ls List linked and unlinked service files up Show status of running services """ } case $1 in link | --link-service ) ln -v -s /etc/sv/"${2}" /var/service/ ;; unlink | --remove-service ) rm -v /var/service/"${2}" ;; linked | --linked-services ) cd /etc/sv && find -xtype l -exec ls -l {} \; ;; list | ls | --list ) echo echo -e "${LGREEN}Available Services (/etc/sv/):${NC}\n" ls /etc/sv echo echo -e "${LCYAN}Running Services (/var/service):${NC}\n" echo ls /var/service echo ;; up ) sv s /var/service/* ;; start ) sv start "${2}" ;; restart ) sv restart "${2}" ;; stop ) sv stop "${2}" ;; --help | -h | help ) help ;; esac