update make-set

This commit is contained in:
artoo 2014-10-07 10:34:33 +02:00
parent 8305472b4f
commit 49c2dc1905

View file

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
if [[ -r @libdir@/functions.sh ]];then
source @libdir@/functions.sh
fi
manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf' manjaro_tools_conf='@sysconfdir@/manjaro-tools.conf'
if [[ -f ${manjaro_tools_conf} ]]; then if [[ -f ${manjaro_tools_conf} ]]; then
@ -12,30 +16,50 @@ else
profiledir='@sysconfdir@/sets' profiledir='@sysconfdir@/sets'
fi fi
profiles=$(get_profiles)
query=false
name='default' 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() { usage() {
echo "Usage: ${0##*/} [options]" echo "Usage: ${0##*/} [options]"
echo " -n <name> Set name without extension" echo " -c <name> Create set"
echo ' -h This help' echo " -q Query sets"
echo ' -h This help'
echo '' echo ''
echo '' echo ''
exit 1 exit 1
} }
opts='n:h' opts='c:qh'
while getopts "${opts}" arg; do while getopts "${opts}" arg; do
case "${arg}" in case "${arg}" in
n) name="$OPTARG" ;; c) name="$OPTARG" ;;
q) query=true ;;
h) usage ;; h) usage ;;
esac esac
done done
shift $(($OPTIND-1))
if [[ $EUID != 0 ]]; then if [[ $EUID != 0 ]]; then
die 'This script must be run as root.' die 'This script must be run as root.'
else fi
for n in $(ls -d $(pwd)/*);do
echo ${n##*/} | sort > ${profiledir}/$1.set if ${query};then
done msg "Sets: ${profiles}"
exit 1
else
write_set
fi fi