manjaro-tools/bin/make-set.in
2014-10-07 10:34:33 +02:00

65 lines
1.1 KiB
Bash

#!/bin/bash
if [[ -r @libdir@/functions.sh ]];then
source @libdir@/functions.sh
fi
manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf'
if [[ -f ${manjaro_tools_conf} ]]; then
. ${manjaro_tools_conf}
fi
if [[ -n ${profiledir} ]];then
profiledir=${profiledir}
else
profiledir='@sysconfdir@/sets'
fi
profiles=$(get_profiles)
query=false
name='default'
write_set(){
local list=$(find * -maxdepth 0 -type d | sort)
if [[ -f ${profiledir}/$name.set ]];then
rm ${profiledir}/$name.set
fi
msg "Creating [${profiledir}/$name.set] ..."
for item in ${list[@]};do
echo ${item##*/} >> ${profiledir}/$name.set || abort
done
}
usage() {
echo "Usage: ${0##*/} [options]"
echo " -c <name> Create set"
echo " -q Query sets"
echo ' -h This help'
echo ''
echo ''
exit 1
}
opts='c:qh'
while getopts "${opts}" arg; do
case "${arg}" in
c) name="$OPTARG" ;;
q) query=true ;;
h) usage ;;
esac
done
shift $(($OPTIND-1))
if [[ $EUID != 0 ]]; then
die 'This script must be run as root.'
fi
if ${query};then
msg "Sets: ${profiles}"
exit 1
else
write_set
fi