]> us-delaporte.pagekite.me Git - minion.git/blob - bin/m2w
README update
[minion.git] / bin / m2w
1 #!/bin/bash
2 # m2w - minion send to wiki
3 # Will publish a maximum of four .md files to .md.txt files
4 # Meant for use wit Dokuwiki
5 # to $M2W_DIR on $M2W_SCP_HOST
6 year=`date +%Y`
7 files=$(find $HOME/Journal/$year -type f -iname "*$1*\.md")
8
9 if [ ! -n "$M2W_DIR" ]; then
10 echo "Set M2W_DIR"
11 exit 1
12 fi
13
14 if [ ! -n "$M2W_HOST" ]; then
15 echo "Set M2W_HOST"
16 exit 1
17 fi
18
19
20 yearmonthday=`date -I`
21
22 counter=0
23 for file in $files; do
24 base=`basename $file .md`
25 # make a backup copy
26 scp $M2W_HOST:$M2W_DIR/$base.txt $HOME/Journal/archive-$year/wiki.backup.$base.$yearmonthday.txt
27
28 # deploy file as .txt
29 scp $file $M2W_HOST:$M2W_DIR/$base.txt
30 counter=$((counter + 1))
31 if [ $counter -gt 4 ]; then
32 echo "Aborting after 4 files."
33 echo "The following files would have been processed..."
34 echo $files
35 exit 1
36 fi
37 done