Marcus Rohrmoser 1 month ago
parent
commit
317f28a109
6 changed files with 64 additions and 59 deletions
  1. 1 1
      .gitignore
  2. 2 2
      README.md
  3. 11 1
      ShaarliGo.go
  4. 37 37
      bindata.go
  5. 11 15
      build.sh
  6. 2 3
      tpl/tools.html

+ 1 - 1
.gitignore

@@ -1,4 +1,4 @@
-ShaarliGo-linux-*-*.*.*
+shaarligo-*-*.cgi*
 testdata/links.atom.bak
 testdata/links.gob
 testdata/sebsauvage.atom

+ 2 - 2
README.md

@@ -58,9 +58,9 @@ URL.
 
 ## Install / Update
 
-Linux amd64:
+bash:
 
-1. `$ curl -L http://purl.mro.name/shaarligo_cgi.gz | tee shaarligo_cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi`
+1. `$ curl -L http://purl.mro.name/shaarligo-$(uname -s)-$(uname -m).cgi.gz | tee shaarligo.cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi`
 2. visit in your browser: http://my.web.space/subdir/shaarligo.cgi
 
 done!

+ 11 - 1
ShaarliGo.go

@@ -28,7 +28,7 @@
 // app/var/stage/
 // app/var/old/
 // assets/default/de/
-// pub/posts/
+// o/p/
 //
 package main
 
@@ -36,6 +36,7 @@ import (
 	"encoding/base64"
 	"encoding/gob"
 	"encoding/xml"
+	"fmt"
 	"io"
 	"log"
 	"net/http"
@@ -68,8 +69,17 @@ func init() {
 func trace(name string) (string, time.Time) { return name, time.Now() }
 func un(name string, start time.Time)       { log.Printf("%s took %s", name, time.Since(start)) }
 
+// are we running cli
+func isCli() bool {
+	return 0 == len(os.Getenv("REQUEST_METHOD"))
+}
+
 // evtl. as a server, too: http://www.dav-muz.net/blog/2013/09/how-to-use-go-and-fastcgi/
 func main() {
+	if isCli() {
+		fmt.Fprintf(os.Stdout, "%sv%s+%s\n", myselfNamespace, version, GitSHA1)
+		return
+	}
 	if false {
 		// lighttpd doesn't seem to like more than one (per-vhost) server.breakagelog
 		log.SetOutput(os.Stderr)

File diff suppressed because it is too large
+ 37 - 37
bindata.go


+ 11 - 15
build.sh

@@ -28,10 +28,9 @@ parm="" # "-u"
 
 "$(go env GOPATH)/bin/go-bindata" -ignore="\\.DS_Store" -ignore=".+\\.woff" -prefix static static/... tpl/...
 
-PROG_NAME="ShaarliGo"
 VERSION="$(grep -F 'version = ' version.go | cut -d \" -f 2)"
 
-rm "${PROG_NAME}"-*-"${VERSION}" 2>/dev/null
+rm "shaarligo"-*-*".cgi"* 2>/dev/null
 
 "${say}" "test"
 umask 0022
@@ -51,25 +50,22 @@ go test -bench=.
 
 "${say}" "linux build"
 # http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
-env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "${PROG_NAME}-linux-amd64-${VERSION}" || { echo "Aua" 1>&2 && exit 1; }
-env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "${PROG_NAME}-linux-arm-${VERSION}" || { echo "Aua" 1>&2 && exit 1; }
-# env GOOS=linux GOARCH=386 GO386=387 go build -o "${PROG_NAME}-linux-386-${VERSION}" # https://github.com/golang/go/issues/11631
-# env GOOS=darwin GOARCH=amd64 go build -o "${PROG_NAME}-darwin-amd64-${VERSION}"
+env GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "shaarligo-Linux-x86_64.cgi" || { echo "Aua" 1>&2 && exit 1; }
+env GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w -X main.GitSHA1=$(git rev-parse --short HEAD)" -o "shaarligo-Linux-armv6l.cgi" || { echo "Aua" 1>&2 && exit 1; }
+# env GOOS=linux GOARCH=386 GO386=387 go build -o "shaarligo-linux-386-${VERSION}" # https://github.com/golang/go/issues/11631
+# env GOOS=darwin GOARCH=amd64 go build -o "shaarligo-darwin-amd64-${VERSION}"
 
 
 "${say}" "simply"
-# scp "ServerInfo.cgi" simply:/var/www/lighttpd/h4u.r-2.eu/public_html/"info.cgi"
-gzip --force --best "${PROG_NAME}"-*-"${VERSION}" \
-&& chmod a-x "${PROG_NAME}"-*-"${VERSION}.gz" \
-&& rsync -vp --bwlimit=1234 "${PROG_NAME}"-*-"${VERSION}.gz" "simply:/tmp/" \
-&& ssh simply "sh -c 'cd /var/www/lighttpd/l.mro.name/public_html/ && cp "/tmp/${PROG_NAME}-linux-amd64-${VERSION}.gz" shaarligo_cgi.gz && gunzip < shaarligo_cgi.gz > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'" \
-&& ssh simply "sh -c 'cd /var/www/lighttpd/b.r-2.eu/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* .'"
-
-ssh simply "sh -c 'cd /var/www/lighttpd/b.mro.name/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* . && ls -l shaarligo?cgi*'"
+gzip --force --best "shaarligo-"*-*".cgi" \
+&& rsync -vp --bwlimit=1234 "shaarligo-"*-*".cgi.gz" "simply:/var/www/lighttpd/l.mro.name/public_html/" \
+&& ssh simply "sh -c 'cd /var/www/lighttpd/l.mro.name/public_html/ && gunzip < shaarligo-$(uname -s)-$(uname -m).cgi.gz > shaarligo.cgi && ls -l shaarligo*cgi*'" \
+&& ssh simply "sh -c 'cd /var/www/lighttpd/b.r-2.eu/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* . && ls -l shaarligo*cgi*'" \
+&& ssh simply "sh -c 'cd /var/www/lighttpd/b.mro.name/public_html/u/ && cp /var/www/lighttpd/l.mro.name/public_html/shaarligo?cgi* . && ls -l shaarligo*cgi*'"
 "${say}" "ok"
 
 "${say}" "vario"
 # scp "ServerInfo.cgi" vario:~/mro.name/webroot/b/"info.cgi"
-ssh vario "sh -c 'cd ~/mro.name/webroot/b/ && curl -L http://purl.mro.name/shaarligo_cgi.gz | tee shaarligo_cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'"
+ssh vario "sh -c 'cd ~/mro.name/webroot/b/ && curl -L http://purl.mro.name/shaarligo-$(uname -s)-$(uname -m).cgi.gz | tee shaarligo.cgi.gz | gunzip > shaarligo.cgi && chmod a+x shaarligo.cgi && ls -l shaarligo?cgi*'"
 "${say}" "ok"
 

+ 2 - 3
tpl/tools.html

@@ -15,10 +15,9 @@
       <br class="br"/>
       <code>$ ssh <kbd>myserver.example.com</kbd><br class="br"/>
 $ cd <kbd>filesystem/path/to/</kbd><br class="br"/>
-$ curl -R -L -o shaarligo.cgi.gz <a href="http://purl.mro.name/shaarligo_cgi.gz">http://purl.mro.name/shaarligo_cgi.gz</a> &amp;&amp; gunzip shaarligo.cgi.gz<br class="br"/>
-$ chmod a+x shaarligo.cgi<br class="br"/>
+$ curl -L http://purl.mro.name/shaarligo-$(uname -s)-$(uname -m).cgi.gz | tee shaarligo.cgi.gz | gunzip &gt;         shaarligo.cgi &amp;&amp; chmod a+x shaarligo.cgi<br class="br"/>
 $ ls -l shaarligo?cgi*<br class="br"/>
-$ rm -rf .htaccess assets app/delete_me_to_restore</code>
+$ rm -rf .htaccess assets app/delete_me_to_restore app/.htaccess app/lighttpd.conf</code>
     </li>
 
     <li id="config"><a href="../config/">Config</a></li>