From 193acce6a730d412801f48adfb9e1751e9deb152 Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Sat, 6 Sep 2014 23:17:15 -0400 Subject: [PATCH 1/3] Improved release scripts in order to produce deb packaes. --- release/INSTALL | 2 -- release/Makefile | 27 +++++++++++++++-- release/debscripts/postinst | 6 ++++ release/debscripts/postrm | 4 +++ release/debscripts/preinst | 5 ++++ release/debscripts/prerm | 4 +++ release/debscripts/run-websocketd | 47 ++++++++++++++++++++++++++++++ release/debscripts/websocketd.conf | 2 ++ 8 files changed, 93 insertions(+), 4 deletions(-) delete mode 100644 release/INSTALL create mode 100755 release/debscripts/postinst create mode 100755 release/debscripts/postrm create mode 100755 release/debscripts/preinst create mode 100755 release/debscripts/prerm create mode 100755 release/debscripts/run-websocketd create mode 100644 release/debscripts/websocketd.conf diff --git a/release/INSTALL b/release/INSTALL deleted file mode 100644 index 5255d30c..00000000 --- a/release/INSTALL +++ /dev/null @@ -1,2 +0,0 @@ -There is nothing to do, just copy websocketd binary into location of your -choice and run it! diff --git a/release/Makefile b/release/Makefile index 8653cb67..d20c4d7b 100644 --- a/release/Makefile +++ b/release/Makefile @@ -19,7 +19,7 @@ LAST_PATCH_VERSION:=$(shell git ls-remote git@github.com:joewalnes/websocketd.gi VERSION_PATCH:=$(if $(LAST_PATCH_VERSION),$(shell expr $(LAST_PATCH_VERSION)),0) RELEASE_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) -GO_VERSION=1.2.2 +GO_VERSION=1.3.1 PLATFORMS=linux_amd64 linux_386 linux_arm darwin_amd64 darwin_386 freebsd_amd64 freebsd_386 windows_386 windows_amd64 GO_SRC_URL=https://storage.googleapis.com/golang/go$(GO_VERSION).src.tar.gz @@ -98,12 +98,35 @@ out/$(RELEASE_VERSION)/%/.built: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) g out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd rm -f $@ - zip -j $@ out/$(RELEASE_VERSION)/$*/.built out/$(RELEASE_VERSION)/$*/* INSTALL ../README.md ../LICENSE + zip -j $@ out/$(RELEASE_VERSION)/$*/.built out/$(RELEASE_VERSION)/$*/* ../{INSTALL,README.md,LICENSE} build: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/.built) $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-$(PLATFORM).zip) .PHONY: build +BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team " --maintainer "abc@alexsergeyev.com" --pre-install debscripts/preinst --post-install debscripts/postinst --before-remove debscripts/prerm --after-remove debscripts/postrm + +DEBFPM=--deb-default debscripts/websocketd --deb-upstart debscripts/websocketd.conf" + + +deb: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb + + +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb: out/$(RELEASE_VERSION)/linux_386/.built + mkdir -p out/$(RELEASE_VERSION)/deb32/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} + cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/deb32/usr/bin/ + cp debscripts/run-websocketd out/$(RELEASE_VERSION)/deb32/usr/libexec/ + cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb32/usr/share/doc/websocketd-$(RELEASE_VERSION) + fpm -f -s dir -t deb -a 386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb32/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb: out/$(RELEASE_VERSION)/linux_amd64/.built + mkdir -p out/$(RELEASE_VERSION)/deb64/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} + cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/deb64/usr/bin/ + cp debscripts/run-websocketd out/$(RELEASE_VERSION)/deb64/usr/libexec/ + cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb64/usr/share/doc/websocketd-$(RELEASE_VERSION) + fpm -f -s dir -t deb -a amd_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + + # release to http://download.websocketd.com/ out/$(RELEASE_VERSION)/%/.released: out/$(RELEASE_VERSION)/%/.built $(call msg,"Uploading $(RELEASE_VERSION) $*") diff --git a/release/debscripts/postinst b/release/debscripts/postinst new file mode 100755 index 00000000..fa88f74d --- /dev/null +++ b/release/debscripts/postinst @@ -0,0 +1,6 @@ +#!/bin/bash + +initctl reload-configuration +echo "Starting websocketd..." +initctl --quiet start websocketd + diff --git a/release/debscripts/postrm b/release/debscripts/postrm new file mode 100755 index 00000000..12166686 --- /dev/null +++ b/release/debscripts/postrm @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Cleanup for websocketd..." +pkill -9 -x websocketd || true diff --git a/release/debscripts/preinst b/release/debscripts/preinst new file mode 100755 index 00000000..7df71b01 --- /dev/null +++ b/release/debscripts/preinst @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Verifying websocketd is stopped..." +initctl --quiet stop websocketd 2>/dev/null || true +pkill -9 -x websocketd || true diff --git a/release/debscripts/prerm b/release/debscripts/prerm new file mode 100755 index 00000000..5e0d47ca --- /dev/null +++ b/release/debscripts/prerm @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Stopping websocketd..." +initctl --quiet stop websocketd || true diff --git a/release/debscripts/run-websocketd b/release/debscripts/run-websocketd new file mode 100755 index 00000000..5f71066f --- /dev/null +++ b/release/debscripts/run-websocketd @@ -0,0 +1,47 @@ +#!/bin/bash + +. /etc/default/websocketd + +if [[ -n "$WEBSOCKETD_ADDRESS" ]]; then + ADDRESS=$(echo $WEBSOCKETD_ADDRESS | xargs -n1 echo | xargs -I'*' echo "--address=*") +fi + +if [[ -n "$WEBSOCKETD_PORT" ]]; then + PORT="--port=$WEBSOCKETD_PORT" +fi + +if [[ -n "$WEBSOCKETD_LOGLEVEL" ]]; then + LOGLEVEL="--loglevel=$WEBSOCKETD_LOGLEVEL" +fi + +if [[ -n "$WEBSOCKETD_STATIC" ]]; then + STATIC="--staticdir=$WEBSOCKETD_STATIC" +fi + +if [[ -n "$WEBSOCKETD_CGI" ]]; then + CGI="--cgidir=$WEBSOCKETD_CGI" +fi + +if [[ -n "$WEBSOCKETD_SCRIPTS" ]]; then + SCRIPTS="--dir=$WEBSOCKETD_SCRIPTS" +fi + +if [[ -n "$WEBSOCKETD_LOOKUP" ]]; then + LOOKUP="--reverselookup=$WEBSOCKETD_LOOKUP" +fi + +if [[ -n "$WEBSOCKETD_SSLCERT" ]]; then + SSL="--ssl --sslcert=$WEBSOCKETD_SSLCERT --sslkey=$WEBSOCKETD_SSLKEY" +fi + + +OPTS="$ADDRESS $PORT $LOGLEVEL $STATIC $CGI $SCRIPTS $LOOKUP $SSL" + + +CMD="/usr/bin/websocketd $OPTS" +if [[ -z "$WEBSOCKETD_USER" ]]; then + exec $CMD +fi + +exec su -s /bin/bash -c "exec $CMD" $WEBSOCKETD_USER + diff --git a/release/debscripts/websocketd.conf b/release/debscripts/websocketd.conf new file mode 100644 index 00000000..db37ce1b --- /dev/null +++ b/release/debscripts/websocketd.conf @@ -0,0 +1,2 @@ +respawn +exec /usr/bin/run-websocketd From 63fba22993a853e94ccabb4480a623453676e67c Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Sun, 7 Sep 2014 22:44:25 -0400 Subject: [PATCH 2/3] Now DEB and RPM packages building is added. Needs some testing. --- release/Makefile | 73 ++++++++++--------- release/debscripts/postinst | 6 -- release/debscripts/postrm | 4 - release/debscripts/preinst | 5 -- release/debscripts/prerm | 4 - .../deb}/websocketd.conf | 0 release/scripts/postinst | 8 ++ release/scripts/preinst | 3 + release/scripts/rpm/websocketd.service | 9 +++ .../{debscripts => scripts}/run-websocketd | 4 +- 10 files changed, 62 insertions(+), 54 deletions(-) delete mode 100755 release/debscripts/postinst delete mode 100755 release/debscripts/postrm delete mode 100755 release/debscripts/preinst delete mode 100755 release/debscripts/prerm rename release/{debscripts => scripts/deb}/websocketd.conf (100%) create mode 100755 release/scripts/postinst create mode 100755 release/scripts/preinst create mode 100644 release/scripts/rpm/websocketd.service rename release/{debscripts => scripts}/run-websocketd (93%) diff --git a/release/Makefile b/release/Makefile index d20c4d7b..f1dad6d0 100644 --- a/release/Makefile +++ b/release/Makefile @@ -15,7 +15,7 @@ LAST_PATCH_VERSION:=$(shell git ls-remote git@github.com:joewalnes/websocketd.gi | sed -e 's/^.*\.//' \ | sort -n \ | tail -n 1) -#VERSION_PATCH:=$(if $(LAST_PATCH_VERSION),$(shell expr $(LAST_PATCH_VERSION) + 1),0) + VERSION_PATCH:=$(if $(LAST_PATCH_VERSION),$(shell expr $(LAST_PATCH_VERSION)),0) RELEASE_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) @@ -47,7 +47,7 @@ EXTENSION_windows_amd64=.exe msg=@/bin/echo -e "\x1b[33;01m>>> $1\x1b[0m" -all: release +all: build deb rpm .PHONY: all go-path/src/github.com/joewalnes/websocketd: @@ -79,8 +79,7 @@ go-unpack: $(GO_UNPACKED) # Cross-compile Go package for target platform $(GO_DIR)/go/pkg/%/.built: $(GO_UNPACKED) $(call msg,"Building Go for $*") - rm -f $@ - cd $(GO_DIR)/go/src && $(FLAGS_$*) ./make.bash --no-clean + cd $(GO_DIR)/go/src && $(FLAGS_$*) ./make.bash --no-clean >/dev/null 2>&1 touch $@ go-compile: $(foreach PLATFORM,$(PLATFORMS),$(GO_DIR)/go/pkg/$(PLATFORM)/.built) @@ -88,7 +87,7 @@ go-compile: $(foreach PLATFORM,$(PLATFORMS),$(GO_DIR)/go/pkg/$(PLATFORM)/.built) # Cross-compile final applications -out/$(RELEASE_VERSION)/%/.built: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd +out/$(RELEASE_VERSION)/%/websocketd: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd $(call msg,"Compiling release for $*") rm -f $@ mkdir -p $(dir $@) @@ -96,54 +95,62 @@ out/$(RELEASE_VERSION)/%/.built: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) g $(FLAGS_$*) $(GO_DIR)/go/bin/go build -ldflags "-X main.version $(RELEASE_VERSION)" -o out/$(RELEASE_VERSION)/$*/websocketd$(EXTENSION_$*) $(wildcard ../*.go) touch $@ -out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/websocketd $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd rm -f $@ - zip -j $@ out/$(RELEASE_VERSION)/$*/.built out/$(RELEASE_VERSION)/$*/* ../{INSTALL,README.md,LICENSE} + zip -j $@ out/$(RELEASE_VERSION)/$*/* ../{INSTALL,README.md,LICENSE} -build: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/.built) $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-$(PLATFORM).zip) -.PHONY: build +build: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/websocketd) $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-$(PLATFORM).zip) +.PHONY: build -BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team " --maintainer "abc@alexsergeyev.com" --pre-install debscripts/preinst --post-install debscripts/postinst --before-remove debscripts/prerm --after-remove debscripts/postrm -DEBFPM=--deb-default debscripts/websocketd --deb-upstart debscripts/websocketd.conf" +BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team " --maintainer "abc@alexsergeyev.com" --pre-install scripts/preinst --post-install scripts/postinst +DEBFPM=--deb-default scripts/websocketd --deb-upstart scripts/deb/websocketd.conf" +RPMFPM=--rpm-os linux deb: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb +rpm: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).x86_64.rpm + -out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb: out/$(RELEASE_VERSION)/linux_386/.built +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd mkdir -p out/$(RELEASE_VERSION)/deb32/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/deb32/usr/bin/ - cp debscripts/run-websocketd out/$(RELEASE_VERSION)/deb32/usr/libexec/ + cp scripts/run-websocketd out/$(RELEASE_VERSION)/deb32/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb32/usr/share/doc/websocketd-$(RELEASE_VERSION) fpm -f -s dir -t deb -a 386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb32/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + rm -rf out/$(RELEASE_VERSION)/deb32/ -out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb: out/$(RELEASE_VERSION)/linux_amd64/.built +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd mkdir -p out/$(RELEASE_VERSION)/deb64/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/deb64/usr/bin/ - cp debscripts/run-websocketd out/$(RELEASE_VERSION)/deb64/usr/libexec/ + cp scripts/run-websocketd out/$(RELEASE_VERSION)/deb64/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb64/usr/share/doc/websocketd-$(RELEASE_VERSION) - fpm -f -s dir -t deb -a amd_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ - - -# release to http://download.websocketd.com/ -out/$(RELEASE_VERSION)/%/.released: out/$(RELEASE_VERSION)/%/.built - $(call msg,"Uploading $(RELEASE_VERSION) $*") - rm -f $@ - s3cmd put --acl-public --mime-type=application/octet-stream out/$(RELEASE_VERSION)/$*/websocketd$(EXTENSION_$*) s3://download.websocketd.com/releases/websocketd/$(RELEASE_VERSION)/$*/websocketd$(EXTENSION_$*) - touch $@ - -release: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/.released) tag -.PHONY: release + fpm -f -s dir -t deb -a amd64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + rm -rf out/$(RELEASE_VERSION)/deb64/ + +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).x86_64.rpm: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd + mkdir -p out/$(RELEASE_VERSION)/rpm64/{usr/bin,etc/default,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system} + cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/rpm64/usr/bin/ + cp scripts/run-websocketd out/$(RELEASE_VERSION)/rpm64/usr/libexec/ + cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm64/usr/share/doc/websocketd-$(RELEASE_VERSION) + cp scripts/rpm/websocketd.service out/$(RELEASE_VERSION)/rpm64/usr/lib/systemd/system + cp scripts/websocketd out/$(RELEASE_VERSION)/rpm64/etc/default/websocketd + fpm -f -s dir -t rpm -a x86_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm64/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) usr/ etc/ + rm -rf out/$(RELEASE_VERSION)/rpm64/ + +out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd + mkdir -p out/$(RELEASE_VERSION)/rpm32/{usr/bin,etc/default,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system} + cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/rpm32/usr/bin/ + cp scripts/run-websocketd out/$(RELEASE_VERSION)/rpm32/usr/libexec/ + cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm32/usr/share/doc/websocketd-$(RELEASE_VERSION) + cp scripts/rpm/websocketd.service out/$(RELEASE_VERSION)/rpm32/usr/lib/systemd/system + cp scripts/websocketd out/$(RELEASE_VERSION)/rpm32/etc/default/websocketd + fpm -f -s dir -t rpm -a i386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm32/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) usr/ etc/ + rm -rf out/$(RELEASE_VERSION)/rpm32/ -# Create remote Git tag -tag: - $(call msg,"Git tagging $(RELEASE_VERSION)") - git tag -a v$(RELEASE_VERSION) -m 'Tagged $(RELEASE_VERSION)' - git push git@github.com:joewalnes/websocketd.git --tags -.PHONY: tag # Clean up diff --git a/release/debscripts/postinst b/release/debscripts/postinst deleted file mode 100755 index fa88f74d..00000000 --- a/release/debscripts/postinst +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -initctl reload-configuration -echo "Starting websocketd..." -initctl --quiet start websocketd - diff --git a/release/debscripts/postrm b/release/debscripts/postrm deleted file mode 100755 index 12166686..00000000 --- a/release/debscripts/postrm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "Cleanup for websocketd..." -pkill -9 -x websocketd || true diff --git a/release/debscripts/preinst b/release/debscripts/preinst deleted file mode 100755 index 7df71b01..00000000 --- a/release/debscripts/preinst +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -echo "Verifying websocketd is stopped..." -initctl --quiet stop websocketd 2>/dev/null || true -pkill -9 -x websocketd || true diff --git a/release/debscripts/prerm b/release/debscripts/prerm deleted file mode 100755 index 5e0d47ca..00000000 --- a/release/debscripts/prerm +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "Stopping websocketd..." -initctl --quiet stop websocketd || true diff --git a/release/debscripts/websocketd.conf b/release/scripts/deb/websocketd.conf similarity index 100% rename from release/debscripts/websocketd.conf rename to release/scripts/deb/websocketd.conf diff --git a/release/scripts/postinst b/release/scripts/postinst new file mode 100755 index 00000000..ffea8d4d --- /dev/null +++ b/release/scripts/postinst @@ -0,0 +1,8 @@ +#!/bin/bash + + +echo "Starting websocketd..." + +if [ -f /sbin/initctl ]; then + initctl reload-configuration +fi diff --git a/release/scripts/preinst b/release/scripts/preinst new file mode 100755 index 00000000..21036e77 --- /dev/null +++ b/release/scripts/preinst @@ -0,0 +1,3 @@ +#!/bin/bash + +adduser --system websocketd -p "!!" --no-create-home --home "/usr/share/websocketd" || true diff --git a/release/scripts/rpm/websocketd.service b/release/scripts/rpm/websocketd.service new file mode 100644 index 00000000..d4eed669 --- /dev/null +++ b/release/scripts/rpm/websocketd.service @@ -0,0 +1,9 @@ +[Unit] +Description=websocketd daemon + +[Service] +Type=simple +ExecStart=/usr/libexec/run-websocketd + +[Install] +WantedBy=multi-user.target diff --git a/release/debscripts/run-websocketd b/release/scripts/run-websocketd similarity index 93% rename from release/debscripts/run-websocketd rename to release/scripts/run-websocketd index 5f71066f..88c06b8e 100755 --- a/release/debscripts/run-websocketd +++ b/release/scripts/run-websocketd @@ -41,7 +41,7 @@ OPTS="$ADDRESS $PORT $LOGLEVEL $STATIC $CGI $SCRIPTS $LOOKUP $SSL" CMD="/usr/bin/websocketd $OPTS" if [[ -z "$WEBSOCKETD_USER" ]]; then exec $CMD +else + exec su -s /bin/bash -c "exec $CMD" $WEBSOCKETD_USER fi -exec su -s /bin/bash -c "exec $CMD" $WEBSOCKETD_USER - From 81c20fd3a04b4f66e4e81455e345740b325600b7 Mon Sep 17 00:00:00 2001 From: Alex Sergeyev Date: Wed, 10 Sep 2014 23:47:07 -0400 Subject: [PATCH 3/3] Simplified packages for deb and rpm. --- release/Makefile | 24 +++++-------- release/scripts/deb/websocketd.conf | 2 -- release/scripts/postinst | 8 ----- release/scripts/preinst | 3 -- release/scripts/rpm/websocketd.service | 9 ----- release/scripts/run-websocketd | 47 -------------------------- 6 files changed, 8 insertions(+), 85 deletions(-) delete mode 100644 release/scripts/deb/websocketd.conf delete mode 100755 release/scripts/postinst delete mode 100755 release/scripts/preinst delete mode 100644 release/scripts/rpm/websocketd.service delete mode 100755 release/scripts/run-websocketd diff --git a/release/Makefile b/release/Makefile index f1dad6d0..afef4b66 100644 --- a/release/Makefile +++ b/release/Makefile @@ -104,9 +104,9 @@ build: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/websoc .PHONY: build -BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team " --maintainer "abc@alexsergeyev.com" --pre-install scripts/preinst --post-install scripts/postinst +BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team " --maintainer "abc@alexsergeyev.com" -DEBFPM=--deb-default scripts/websocketd --deb-upstart scripts/deb/websocketd.conf" +DEBFPM="" RPMFPM=--rpm-os linux deb: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb @@ -115,39 +115,31 @@ rpm: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm out/$(RELEASE out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd - mkdir -p out/$(RELEASE_VERSION)/deb32/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} + mkdir -p out/$(RELEASE_VERSION)/deb32/{usr/bin,usr/share/doc/websocketd-$(RELEASE_VERSION)} cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/deb32/usr/bin/ - cp scripts/run-websocketd out/$(RELEASE_VERSION)/deb32/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb32/usr/share/doc/websocketd-$(RELEASE_VERSION) - fpm -f -s dir -t deb -a 386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb32/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + fpm -f -s dir -t deb -a 386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb32/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ rm -rf out/$(RELEASE_VERSION)/deb32/ out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd - mkdir -p out/$(RELEASE_VERSION)/deb64/{usr/bin,etc/default,etc/init,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION)} + mkdir -p out/$(RELEASE_VERSION)/deb64/{usr/bin,usr/share/doc/websocketd-$(RELEASE_VERSION)} cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/deb64/usr/bin/ - cp scripts/run-websocketd out/$(RELEASE_VERSION)/deb64/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/deb64/usr/share/doc/websocketd-$(RELEASE_VERSION) - fpm -f -s dir -t deb -a amd64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ etc/ + fpm -f -s dir -t deb -a amd64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/ rm -rf out/$(RELEASE_VERSION)/deb64/ out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).x86_64.rpm: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd mkdir -p out/$(RELEASE_VERSION)/rpm64/{usr/bin,etc/default,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system} cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/rpm64/usr/bin/ - cp scripts/run-websocketd out/$(RELEASE_VERSION)/rpm64/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm64/usr/share/doc/websocketd-$(RELEASE_VERSION) - cp scripts/rpm/websocketd.service out/$(RELEASE_VERSION)/rpm64/usr/lib/systemd/system - cp scripts/websocketd out/$(RELEASE_VERSION)/rpm64/etc/default/websocketd - fpm -f -s dir -t rpm -a x86_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm64/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) usr/ etc/ + fpm -f -s dir -t rpm -a x86_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm64/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) $(RPMFPM) usr/ rm -rf out/$(RELEASE_VERSION)/rpm64/ out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd mkdir -p out/$(RELEASE_VERSION)/rpm32/{usr/bin,etc/default,usr/libexec,usr/share/websocketd,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system} cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/rpm32/usr/bin/ - cp scripts/run-websocketd out/$(RELEASE_VERSION)/rpm32/usr/libexec/ cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm32/usr/share/doc/websocketd-$(RELEASE_VERSION) - cp scripts/rpm/websocketd.service out/$(RELEASE_VERSION)/rpm32/usr/lib/systemd/system - cp scripts/websocketd out/$(RELEASE_VERSION)/rpm32/etc/default/websocketd - fpm -f -s dir -t rpm -a i386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm32/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) usr/ etc/ + fpm -f -s dir -t rpm -a i386 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm32/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) $(RPMFPM) usr/ rm -rf out/$(RELEASE_VERSION)/rpm32/ diff --git a/release/scripts/deb/websocketd.conf b/release/scripts/deb/websocketd.conf deleted file mode 100644 index db37ce1b..00000000 --- a/release/scripts/deb/websocketd.conf +++ /dev/null @@ -1,2 +0,0 @@ -respawn -exec /usr/bin/run-websocketd diff --git a/release/scripts/postinst b/release/scripts/postinst deleted file mode 100755 index ffea8d4d..00000000 --- a/release/scripts/postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - - -echo "Starting websocketd..." - -if [ -f /sbin/initctl ]; then - initctl reload-configuration -fi diff --git a/release/scripts/preinst b/release/scripts/preinst deleted file mode 100755 index 21036e77..00000000 --- a/release/scripts/preinst +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -adduser --system websocketd -p "!!" --no-create-home --home "/usr/share/websocketd" || true diff --git a/release/scripts/rpm/websocketd.service b/release/scripts/rpm/websocketd.service deleted file mode 100644 index d4eed669..00000000 --- a/release/scripts/rpm/websocketd.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=websocketd daemon - -[Service] -Type=simple -ExecStart=/usr/libexec/run-websocketd - -[Install] -WantedBy=multi-user.target diff --git a/release/scripts/run-websocketd b/release/scripts/run-websocketd deleted file mode 100755 index 88c06b8e..00000000 --- a/release/scripts/run-websocketd +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -. /etc/default/websocketd - -if [[ -n "$WEBSOCKETD_ADDRESS" ]]; then - ADDRESS=$(echo $WEBSOCKETD_ADDRESS | xargs -n1 echo | xargs -I'*' echo "--address=*") -fi - -if [[ -n "$WEBSOCKETD_PORT" ]]; then - PORT="--port=$WEBSOCKETD_PORT" -fi - -if [[ -n "$WEBSOCKETD_LOGLEVEL" ]]; then - LOGLEVEL="--loglevel=$WEBSOCKETD_LOGLEVEL" -fi - -if [[ -n "$WEBSOCKETD_STATIC" ]]; then - STATIC="--staticdir=$WEBSOCKETD_STATIC" -fi - -if [[ -n "$WEBSOCKETD_CGI" ]]; then - CGI="--cgidir=$WEBSOCKETD_CGI" -fi - -if [[ -n "$WEBSOCKETD_SCRIPTS" ]]; then - SCRIPTS="--dir=$WEBSOCKETD_SCRIPTS" -fi - -if [[ -n "$WEBSOCKETD_LOOKUP" ]]; then - LOOKUP="--reverselookup=$WEBSOCKETD_LOOKUP" -fi - -if [[ -n "$WEBSOCKETD_SSLCERT" ]]; then - SSL="--ssl --sslcert=$WEBSOCKETD_SSLCERT --sslkey=$WEBSOCKETD_SSLKEY" -fi - - -OPTS="$ADDRESS $PORT $LOGLEVEL $STATIC $CGI $SCRIPTS $LOOKUP $SSL" - - -CMD="/usr/bin/websocketd $OPTS" -if [[ -z "$WEBSOCKETD_USER" ]]; then - exec $CMD -else - exec su -s /bin/bash -c "exec $CMD" $WEBSOCKETD_USER -fi -