summaryrefslogtreecommitdiff
path: root/www/fswiki/files/setup.sh
blob: 2c68af2025030f3287f60bfc07a269e5743ef0e2 (plain)
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
#!/bin/sh
#
# setup_fswiki: a script for setup the current directory for fswiki
#
# Stolen from: FreeBSD: ports/www/aswiki/files/setup.sh,v 1.2 2003/06/20 10:46:30 matusita Exp
#
# $FreeBSD$

ask_noyes()
{
	local key

	echo -n "$1 [y/N]: "
	read key
	case "$key" in
	[Yy]*)
		return 0;;
	*)
		return 1;;
	esac
} 

ask_copy()
{
	local file ans
	file=$1

	if [ -f ./$file ]; then
		if ask_noyes "Overwrite $file?"; then
			ans=YES
		else
			ans=NO
		fi
	else
		ans=YES
	fi
	if [ $ans = "YES" ]; then
		install -m 644 __DATADIR__/$file $file
	else
		echo "$file is untouched; you may update with __DATADIR__/$file."
	fi
}

echo "This script will setup current directory for fswiki."
if ask_noyes "Are you ready?"; then
	echo -n "Creating directories..."
	mkdir backup config data log
	echo "done."
	echo -n "Copying files..."
	ask_copy config/config.dat
	ask_copy config/farmconf.dat
	ask_copy config/mime.dat
	ask_copy config/plugin.dat
	ask_copy config/user.dat
	ask_copy config/usercss.dat
	ask_copy data/FrontPage.wiki
	ask_copy data/Help%2FFSWiki.wiki
	ask_copy data/Help%2FHiki.wiki
	ask_copy data/Help%2FYukiWiki.wiki
	ask_copy data/Help.wiki
	ask_copy setup.dat
	ask_copy wiki.cgi
	chmod +x wiki.cgi
	ln -sf __DATADIR__/docs
	ln -sf __DATADIR__/lib
	ln -sf __DATADIR__/plugin
	ln -sf __DATADIR__/theme
	ln -sf __DATADIR__/tmpl
	echo "done."
else
	echo "Stopped."
	exit 1
fi