aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-06-15 12:50:43 -0400
committerU-AD\carlsoan <carlsoan@gophersjos7275.ad.uc.edu>2018-06-15 12:50:43 -0400
commit282d41cac89fe13d777f37c499cc86245df51ce8 (patch)
tree60f1f3a3c6f220b962d94f98e55ad789372981cd
parent61827856820e8c50114570b9f0852f52af48a952 (diff)
working on configure
-rw-r--r--Makefile.m421
-rw-r--r--cgitrc11
-rw-r--r--configure61
3 files changed, 82 insertions, 11 deletions
diff --git a/Makefile.m4 b/Makefile.m4
new file mode 100644
index 0000000..ec7ecc4
--- /dev/null
+++ b/Makefile.m4
@@ -0,0 +1,21 @@
+define getsetting
+$$(grep "^$(2)[ \t]*" $(1) | sed 's/^$(2)[ \t]*//g')
+endef
+
+all: 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
+
+apacheconf: build tmp/settings.txt
+
+tmp/settings.txt
+
diff --git a/cgitrc b/cgitrc
deleted file mode 100644
index bc93012..0000000
--- a/cgitrc
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# cgit config
-# see cgitrc(5) for details
-
-css=/cgit-css/cgit.css
-logo=/cgit-css/adt-git.png
-#logo=/cgit-css/cgit.png
-# about-filter=/usr/local/bin/pretext.sh
-about-filter=/usr/local/bin/md2html.sh
-readme=:README.md
-scan-path=/git
diff --git a/configure b/configure
index ba73a2a..a2464eb 100644
--- a/configure
+++ b/configure
@@ -1,5 +1,51 @@
#!/bin/bash
+newsetting() {
+ read -p "$1 [$3]: " thisset
+ if [ -z "$thisset" ]; then
+ echo "$2 $3" >> $4
+ else
+ echo "$2 $thisset" | sed 's/\/$//g' >> $4
+ fi
+}
+
+checkdistro() {
+ echo -n "Checking distro..."
+ isdebian="$(cat /etc/*release* | grep -i 'debian')"
+ iscentos="$(cat /etc/*release* | grep -i 'centos')"
+ if [ ${#isdebian} -gt 0 ]; then
+ echo "debian"
+ echo "DISTRO debian" >> $1
+ fi
+ if [ ${#centos} -gt 0 ]; then
+ echo "centos"
+ echo "DISTRO centos" >> $1
+ fi
+ if [ ${#isdebian} -eq 0 ] && [ ${#iscentos} -eq 0 ]; then
+ echo "error"
+ 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)
+}
+
+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)
+}
+
checkfile() {
echo -n "Checking $@..."
[[ -f $@ ]] && echo "ok" || (echo "error" ; exit)
@@ -10,3 +56,18 @@ checkbin() {
which $@ > /dev/null
[[ $? -eq 0 ]] && echo "ok" || ( echo "error" ; exit)
}
+
+
+
+# Perform Checks
+checkbin pandock
+checkfile /etc/cgitrc
+checkbinlist /usr/sbin/httpd /usr/sbin/apache2
+
+checkdistro 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