aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-06-15 15:35:08 -0400
committerU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-06-15 15:35:08 -0400
commitdefd983003d785d11ac3ab7114470010e7a5f60b (patch)
tree0c9b2be10079f21279498fccd979646edb22321a
parent11a652de9a34b4393ac4181f8f49c6c77ef29a1e (diff)
updated make, configure, m4
-rw-r--r--Makefile.m435
-rw-r--r--cgitrc.m49
-rwxr-xr-x[-rw-r--r--]configure58
-rwxr-xr-xfilters/md2html.sh5
-rwxr-xr-xfilters/pretext.sh6
5 files changed, 82 insertions, 31 deletions
diff --git a/Makefile.m4 b/Makefile.m4
index ec7ecc4..d9b6c13 100644
--- a/Makefile.m4
+++ b/Makefile.m4
@@ -1,21 +1,30 @@
+FILTERs := FILTERLIST
+
define getsetting
$$(grep "^$(2)[ \t]*" $(1) | sed 's/^$(2)[ \t]*//g')
endef
-all: cgitrc
+all: $(FILTERS) build/cgitrc build/cgit.conf build/cgit.php
+
+build/cgitrc: build
+ m4 -DCGITCSS="$(call getsetting,tmp/settings.txt,CGITCSS)" -DGITPATH="$(call getsetting,tmp/settings.txt,GITPATH)" cgitrc.m4 > build/cgitrc
-cgitrc: build tmp/settings.txt
- cp /etc/cgitrc build/cgitrc
- echo "# Uncomment one of the below 'about-filter' lines to enable readme file transformation" >> build/cgitrc
- echo "#about-filter=/usr/local/bin/pretext.sh" >> build/cgitrc
- echo "#about-filter=/usr/local/bin/md2html.sh" >> build/cgitrc
- echo "" >> build/cgitrc
- echo "# Uncomment one of the below 'readme' lines to enable readme files" >> build/cgitrc
- echo "#readme=:README.md" >> build/cgitrc
- echo "#readme=:README" >> build/cgitrc
- echo "scan-path=$(call getsetting,tmp/settings.txt,GITPATH)" >> build/cgitrc
+build/cgit.conf: build
+ echo "<Macro CgitPage \$url>" > build/cgit.conf
+ sed 's/^ScriptAlias.*$/ScriptAlias \/$url\/ "\/usr\/lib\/cgit\/cgit.cgi\/"/g;s/^RedirectMatch.*$/RedirectMatch ^$url$ $url\//g' $(call getsetting,tmp/settings.txt,CGITCONF) >> build/cgit.conf
+ echo "</Macro>" >> build/cgit.conf
-apacheconf: build tmp/settings.txt
+build/cigit.php: build
+ m4 -DCGITURL="$(call getsetting,tmp/settings.txt,CGITURL)" cgit.php.m4 > build/cgit.php
-tmp/settings.txt
+$(FILTERS): build/filters
+ cp $$(sed 's/^build\///g' <<< "$@") $@
+build/filters: build
+ mkdir -p build/filters
+
+build:
+ mkdir -p build
+
+clean:
+ rm -rf build
diff --git a/cgitrc.m4 b/cgitrc.m4
new file mode 100644
index 0000000..f5fbf00
--- /dev/null
+++ b/cgitrc.m4
@@ -0,0 +1,9 @@
+css=CGITCSS/cgit.css
+logo=CGITCSS/cgit.png
+# Uncomment one of the below 'about-filter' lines to enable readme file transformation" >> build/cgitrc
+#about-filter=/usr/local/bin/pretext.sh
+#about-filter=/usr/local/bin/md2html.sh
+# Uncomment one of the below 'readme' lines to enable readme files
+#readme=:README.md
+#readme=:README
+scan-path=GITPATH
diff --git a/configure b/configure
index a2464eb..0e20627 100644..100755
--- a/configure
+++ b/configure
@@ -9,6 +9,10 @@ newsetting() {
fi
}
+getsetting() {
+ grep "^$2[ \t]*" $1 | sed 's/^'"$2"'[ \t]*//g'
+}
+
checkdistro() {
echo -n "Checking distro..."
isdebian="$(cat /etc/*release* | grep -i 'debian')"
@@ -22,28 +26,45 @@ checkdistro() {
echo "DISTRO centos" >> $1
fi
if [ ${#isdebian} -eq 0 ] && [ ${#iscentos} -eq 0 ]; then
- echo "error"
+ echo "Requires CentOS or Debian"
exit
fi
}
-checkbinlist() {
- binfound="0"
- echo "$@" | tr ' ' '\n' | while read line; do
- echo -n "Checking $line..."
- which $line > /dev/null
- [[ $? -eq 0 ]] && (echo "ok" ; export binfound="1" ; break) || echo "failed"
- done
- [[ "$1" == "0" ]] && (echo "Requires one of these: $@" ; exit)
+checkapache() {
+ echo -n "Checking Apache..."
+ if [ "$(getsetting $1 DISTRO)" == "centos" ]; then
+ which /usr/sbin/httpd > /dev/null
+ [[ $? -eq 0 ]] && echo "ok" || (echo "error" ; exit)
+ fi
+ if [ "$(getsetting $1 DISTRO)" == "debian" ]; then
+ which /usr/sbin/apache2 > /dev/null
+ [[ $? -eq 0 ]] && echo "ok" || (echo "error"; exit)
+ fi
}
-checkfilelist() {
- filefound="0"
- echo "$@" | tr ' ' '\n' | while read line; do
- echo -n "Checking $line..."
- [[ -f $line ]] && (echo "ok" ; export filefound="1"; break) || echo "failed"
- done
- [[ "$1" == "0" ]] && (echo "Requires one of these: $@" ; exit)
+checkcgit() {
+ echo -n "Checking cgit..."
+ if [ "$(getsetting $1 DISTRO)" == "centos" ]; then
+ if [ -f /etc/httpd/conf.d/cgit.conf ]; then
+ echo "ok"
+ echo "CGITCONF /etc/httpd/conf.d/cgit.conf" >> $1
+ echo "CGITCSS cgit-data" >> $1
+ else
+ echo "error"
+ exit
+ fi
+ fi
+ if [ "$(getsetting $1 DISTRO)" == "debian" ]; then
+ if [ -f /etc/apache2/conf-enabled/cgit.conf ]; then
+ echo "ok"
+ echo "CGITCONF /etc/apache2/conf-enabled/cgit.conf" >> $1
+ echo "CGITCSS cgit-css" >> $1
+ else
+ echo "error"
+ exit
+ fi
+ fi
}
checkfile() {
@@ -62,12 +83,13 @@ checkbin() {
# Perform Checks
checkbin pandock
checkfile /etc/cgitrc
-checkbinlist /usr/sbin/httpd /usr/sbin/apache2
checkdistro tmp/settings.txt
+checkapache tmp/settings.txt
+checkcgit tmp/settings.txt
# Save Settings
newsetting "Enter the path for git repositories" "GITPATH" "/opt/repos" tmp/settings.txt
newsetting "Enter cgit URL" "GITURL" "http://localhost/git" tmp/settings.txt
-mv Makefile.m4
+m4 -DFILTERLIST="$(find filters/ -type f | sed 's/^/build\//g' | tr '\n' ' ')" Makefile.m4 > Makefile
diff --git a/filters/md2html.sh b/filters/md2html.sh
new file mode 100755
index 0000000..dcad4d9
--- /dev/null
+++ b/filters/md2html.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cat -| sed 's/</\&lt;/g;s/>/\&gt;/g' | pandoc -f markdown -t html
+
+echo "<br/><br/><a href="../tree">View Code</a>"
diff --git a/filters/pretext.sh b/filters/pretext.sh
new file mode 100755
index 0000000..e5beaa3
--- /dev/null
+++ b/filters/pretext.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+echo "<pre style=\"width:100%;white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;\">"
+cat - | sed 's/</\&lt;/g;s/>/\&gt;/g'
+echo "</pre>"
+echo "<br/><br/><a href="../tree">View Code</a>"