Commit 75592018 authored by Ivanq's avatar Ivanq

Save hooks

parent ff23b4fa
#!/bin/bash
sign=1
publish=1
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
no-sign)
sign=0
;;
no-publish)
publish=0
;;
esac
i=$((i + 1))
done
fi
if [ $sign -eq 0 ]; then
echo "no-sign rejects signing, rejecting."
exit 0
fi
################################################################################
zeronet_home=`git config --get zeronet.home`
if [ -z "$zeronet_home" ]; then
echo "zeronet.home not set, rejecting to sign."
echo "Run 'git config --global zeronet.home path_to_zeronet'"
exit 0
fi
site=`basename $(realpath "$GIT_DIR/..")`
python_path=`command -v python`
if [ -z "$python_path" ]; then
python_path=`command -v python2`
fi
if [ -z "$python_path" ]; then
echo "Python not installed, rejecting to sign."
exit 0
fi
################################################################################
echo "Retrieving data directory..."
data_dir=`"$python_path" "$zeronet_home/zeronet.py" --silent getConfig | "$python_path" -c "import sys, json; config = json.load(sys.stdin); print config['data_dir']"`
privatekey=`cat "$data_dir/users.json" | "$python_path" -c "import sys, json; users = json.load(sys.stdin); print users[users.keys()[0]]['certs']['zeroid.bit']['auth_privatekey']"`
if [ $? -ne 0 ]; then
echo "Failed to get signing key, rejecting to sign."
exit 0
fi
echo "Signing..."
"$python_path" "$zeronet_home/zeronet.py" siteSign "$site" "$privatekey" 2>&1 | grep "Private key invalid" >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Failed to sign, invalid private key. Probably you are not a maintainer."
exit 0
fi
if [ $publish -eq 0 ]; then
echo "no-publish rejects publishing, rejecting."
echo "Signed successfully"
exit 0
fi
echo "Publishing..."
"$python_path" "$zeronet_home/zeronet.py" sitePublish "$site" >/dev/null 2>&1
echo "Signed & published successfully"
\ No newline at end of file
#!/bin/bash
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
no-fetch)
echo "no-fetch cancels fetching, returning."
exit 0
;;
esac
i=$((i + 1))
done
fi
################################################################################
python_path=`command -v python`
if [ -z "$python_path" ]; then
python_path=`command -v python2`
fi
if [ -z "$python_path" ]; then
exit 0
fi
"$python_path" -c "import socket; s = socket.socket(); s.settimeout(2); s.connect(('127.0.0.1', 43110)); s.close()" >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "ZeroNet already running, skipping fetching."
exit 0
fi
echo "Fetching ZeroNet..."
"$python_path" "$zeronet_home/zeronet.py" siteDownload "$site" >/dev/null 2>&1
exit 0
\ No newline at end of file
......@@ -926,6 +926,16 @@ Git.init = (root, zeroPage, name, email) => {
return git.setRef("refs/heads/master", id);
})
.then(() => {
return git;
});
return zeroFS.readFile("assets/post-receive");
})
.then(postReceive => {
return zeroFS.writeFile(root + "/hooks/post-receive", postReceive);
})
.then(() => {
return zeroFS.readFile("assets/pre-receive");
})
.then(preReceive => {
return zeroFS.writeFile(root + "/hooks/pre-receive", preReceive);
})
.then(() => git);
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment