about summary refs log tree commit diff stats
path: root/pub.sh
blob: 19351a7471ba72b446fd9b04a0d3c32de4021329 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

. pub.conf

fn_clean() {
	printf "Cleaning... \n"
	find . -name "*.gmi" -delete
	find . -name "*.htm" -delete
}

fn_generate() {
	txt convert --type=gmi gmi/
	txt convert --type=htm www/
}

fn_index() {
	printf "Creating index.pck... \n"
	txt index --title=$title --authors="$author" --locations="$locations" --peers="$peers" .

	printf "Replicating index.pck... \n"
	for p in gmi gph www; do cp index.pck $p/index.pck; done
}

fn_link() {
	for p in gmi gph www;
	do
		txt file *.txt $p 2>&-
	done
}

fn_unlink() {
	for p in gmi gph www;
	do
		rm -f $p/*.txt
	done
}

fn_upload_gmi() {
	rsync -acv --exclude '*.txt' --exclude '.convert.conf' --delete gmi/ $username@$gmi_srv:$gmi_dir
}

fn_upload_gph() {
	rsync -acv gph/ $username@$gph_srv:$gph_dir
}

fn_upload_www() {
	rsync -acv www/ $username@$www_srv:$www_dir
}

fn_usage() {
	printf "Usage [ clean | generate | index | link | upload ] \n"
}

main() {
	case $1 in
		clean) 
			fn_clean 
			;;
		generate) 
			fn_generate 
			;;
		index) 
			fn_index 
			;;
		link)
			fn_unlink
			fn_link 
			;;
		upload) 
			fn_upload_gmi
			fn_upload_gph
			fn_upload_www
			;;
		*) 
			fn_usage 
			;;
	esac
}

main "$@"