Mini Shell

Direktori : /usr/bin/
Upload File :
Current File : //usr/bin/libcare-cron

#!/usr/bin/bash
# vi:syntax=sh

set -eo pipefail


progname=$(basename "$0")

sub_help(){
    echo "Usage: $progname <subcommand> [options]\n"
    echo "Subcommands:"
    echo "    init"
    echo "    disable"
    echo ""
    echo "For help with each subcommand run:"
    echo "$progname <subcommand> -h|--help"
    echo ""
}

LIBCARE_CRONFILE=/etc/cron.d/libcare-cron

subcommand=$1

sub_disable(){
    if [[ -e ${LIBCARE_CRONFILE} && -s ${LIBCARE_CRONFILE} ]]; then
        rm ${LIBCARE_CRONFILE}
    fi
}

sub_init(){
    if ! [[ -e ${LIBCARE_CRONFILE} && -s ${LIBCARE_CRONFILE} ]]; then
      echo "$(( RANDOM % 60 )) */4  * * * root /usr/bin/kcarectl -q --lib-auto-update" > ${LIBCARE_CRONFILE}
    fi
}


case $subcommand in
    "" | "-h" | "--help")
        sub_help
        ;;
    *)
        shift
        sub_${subcommand} $@
        if [ $? = 127 ]; then
            echo "Error: '$subcommand' is not a known subcommand." >&2
            echo "       Run '$progname --help' for a list of known subcommands." >&2
            exit 1
        fi
        ;;
esac

echo "Done."

Zerion Mini Shell 1.0