-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinit
More file actions
executable file
·86 lines (68 loc) · 1.92 KB
/
Copy pathinit
File metadata and controls
executable file
·86 lines (68 loc) · 1.92 KB
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
81
82
83
84
85
86
#!/bin/bash
if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" || -z "$5" ]]; then
echo "scripts/init hostname port email username password"
exit 1
fi
. scripts/functions
hostname=${1}
port=${2}
email=${3}
nokey=1
gpg=$(findGPG)
if [ -z "$gpg" ]; then
echo "Could not find GPG executable on the \$PATH"
exit 1
fi
keyemails=$($gpg --list-keys 2> /dev/null | grep ^uid 2> /dev/null | perl -ne '/<(.*)>/ && print $1."\n"')
if [[ -z "${keyemails}" ]]; then
echo "No GPG keys. You need to create at least one."
exit 1
fi
for keyemail in ${keyemails}; do
if [[ "${keyemail}" == "${email}" ]]; then
nokey=0
fi
done
if [[ ${nokey} == 1 ]]; then
echo "Key for email ${email} not found. Please create it or verify your email address."
exit 1
fi
# Initialize the repository
mkdir -p posts data config public repos
touch following
echo $1 > config/hostname
echo $2 > config/port
echo $3 > config/email
echo $4 > config/user
echo $5 > config/password
echo "A gitgeist site" > config/title
# Export the key we'll use for this repository.
if [[ ! -f data/key.gpg ]]; then
$gpg --armor --output data/key.gpg --export $3
fi
# Initialize the local git repository for the content.
git init
git config http.receivePack true
git config receive.denyCurrentBranch ignore
echo "data" > .gitignore
echo "scripts" >> .gitignore
echo "public" >> .gitignore
touch data/followers
touch data/following
touch .git/git-daemon-export-ok
cp scripts/data/style.css .
cp scripts/data/logo.png .
cp scripts/getkeyid .
cp scripts/functions .
git add posts
git add following
git add style.css
git add getkeyid
git add functions
git commit -m "Initialisation commit."
# Copy the GPG update hook in place.
ln -fs $(pwd)/scripts/hook-update $(pwd)/.git/hooks/update
ln -fs $(pwd)/scripts/hook-post-update $(pwd)/.git/hooks/post-update
ln -fs $(pwd)/scripts/hook-post-commit $(pwd)/.git/hooks/post-commit
# Generate the first page
scripts/gen