Merge branch 'master' of /srv/foundation/MiscScripts

This commit is contained in:
DarkFeather 2017-09-07 00:25:28 -05:00
commit 7816b0923f
1 changed files with 60 additions and 0 deletions

60
Shared/worktrack Normal file
View File

@ -0,0 +1,60 @@
#!/bin/bash
command="$1"
option="$2"
# Sanity checks
if [ ! -x "$(which libreoffice)" ]; then
echo Needs libreoffice.
exit 1;
fi
if [ ! -f /opt/worktrack/template.odt ]; then
echo Needs template document in /opt/worktrack/template.odt
exit 1;
fi
case "$command" in
"new")
# Start a new project
mkdir -p ~/Documents/WorkTrack/"$option"
cp /opt/worktrack/template.odt ~/Documents/WorkTrack/"$option"/track.odt
chmod u+w ~/Documents/WorkTrack/"$option"/track.odt
exec libreoffice --writer ~/Documents/WorkTrack/"$option"/track.odt
;;
"list")
# Show available projects
ls -l ~/Documents/WorkTrack
;;
"complete")
# Hide a project from listing.
mv ~/Documents/WorkTrack/"$option" ~/Documents/WorkTrack/\."$option"
;;
"cd")
# enter the directory
cd ~/Documents/WorkTrack/"$option"
if [ $? -eq 0 ]; then exec /bin/bash; fi
;;
"purge")
# Remove all completed projects
rm -Ri ~/Documents/WorkTrack/\.[a-zA-Z1-9]*
;;
"edit")
exec libreoffice --writer ~/Documents/WorkTrack/"$option"/track.odt
;;
"checkperm")
if [ `whoami` != "root" ]; then
echo "Need to be root."
exit 1;
fi
chown root: /opt/worktrack/template.odt /usr/local/bin/worktrack
chmod 0755 /usr/local/bin/worktrack
chmod 0644 /opt/worktrack/template.odt
;;
*)
echo Usage: $0 '[command]'
echo Available commands:
egrep '\"\) *$' $0 | cut -f 2 -d '"'
exit 1;
;;
esac
exit 0