manjaro-tools/bin/make-set.in

83 lines
1.7 KiB
Text
Raw Normal View History

2014-10-07 01:16:29 +02:00
#!/bin/bash
2014-10-08 11:11:19 +02:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
2014-10-07 01:16:29 +02:00
2014-10-08 00:12:14 +02:00
if [[ -r @libdir@/messages.sh ]];then
source @libdir@/messages.sh
fi
if [[ -r @libdir@/build-api.sh ]];then
source @libdir@/build-api.sh
2014-10-07 10:34:33 +02:00
fi
2014-10-07 01:16:29 +02:00
manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf'
if [[ -f ${manjaro_tools_conf} ]]; then
2014-10-08 11:11:19 +02:00
source ${manjaro_tools_conf}
2014-10-07 01:16:29 +02:00
fi
if [[ -n ${profiledir} ]];then
profiledir=${profiledir}
else
profiledir='@sysconfdir@/sets'
fi
2014-10-08 11:11:19 +02:00
run(){
if ${create};then
create_set
elif ${remove};then
remove_set
elif ${display};then
display_set
else
msg "Available sets: ${profiles}"
exit 1
fi
}
2014-10-07 10:34:33 +02:00
profiles=$(get_profiles)
query=false
2014-10-07 17:27:39 +02:00
create=false
remove=false
2014-10-07 23:06:20 +02:00
display=false
2014-10-07 01:16:29 +02:00
name='default'
usage() {
echo "Usage: ${0##*/} [options]"
2014-10-07 10:34:33 +02:00
echo " -c <name> Create set"
2014-10-07 17:27:39 +02:00
echo " -r <name> Remove set"
2014-10-07 23:06:20 +02:00
echo " -d <name> Display set"
2014-10-07 10:34:33 +02:00
echo " -q Query sets"
echo ' -h This help'
2014-10-07 01:16:29 +02:00
echo ''
echo ''
exit 1
}
2014-10-07 23:06:20 +02:00
opts='c:r:d:qh'
2014-10-07 01:16:29 +02:00
while getopts "${opts}" arg; do
case "${arg}" in
2014-10-07 17:27:39 +02:00
c) name="$OPTARG"; create=true ;;
r) name="$OPTARG"; remove=true ;;
2014-10-07 10:34:33 +02:00
q) query=true ;;
2014-10-07 23:06:20 +02:00
d) name="$OPTARG"; display=true;;
2014-10-07 01:16:29 +02:00
h) usage ;;
esac
done
2014-10-07 17:27:39 +02:00
shift $(($OPTIND - 1))
2014-10-07 10:34:33 +02:00
2014-10-07 01:16:29 +02:00
if [[ $EUID != 0 ]]; then
die 'This script must be run as root.'
2014-10-07 10:34:33 +02:00
fi
2014-10-08 11:11:19 +02:00
run $@