61 lines
1.6 KiB
Plaintext
61 lines
1.6 KiB
Plaintext
|
#!/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
|