Add packaging instructions and script
This commit is contained in:
parent
90269e40e5
commit
bed3e755f7
|
|
@ -0,0 +1,40 @@
|
|||
# Packaging
|
||||
|
||||
## Build libraries as shared
|
||||
|
||||
In order to packaged the project, you will need to follow those different steps.
|
||||
We will build libraries as shared libraries.
|
||||
|
||||
The first step is to buid the GO standard library as shared.
|
||||
```
|
||||
$ cd $GOPATH
|
||||
$ go install -buildmode=shared std
|
||||
```
|
||||
|
||||
Next, we will build the 2 libraries to make them shared…
|
||||
```
|
||||
$ cd $GOPATH
|
||||
$ go install -buildmode=shared -linkshared github.com/jimlawless/cfg
|
||||
$ go install -buildmode=shared -linkshared git.kingpenguin.tk/chteufleur/go-xmpp.git/src/xmpp
|
||||
```
|
||||
|
||||
Then finally, build the project with the option that tell to use libraries as shared and not static.
|
||||
```
|
||||
$ cd $GOPATH
|
||||
$ go install -linkshared git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP.git
|
||||
```
|
||||
|
||||
You will find shared libraries over here :
|
||||
* ``$GOROOT/pkg/linux_amd64_dynlink/libstd.so``
|
||||
* ``$GOPATH/pkg/linux_amd64_dynlink/libgithub.com-jimlawless-cfg.so``
|
||||
* ``$GOPATH/pkg/linux_amd64_dynlink/libgit.kingpenguin.tk-chteufleur-go-xmpp.git-src-xmpp.so``
|
||||
|
||||
And the binary file here :
|
||||
* ``$GOPATH/bin/HTTPAuthentificationOverXMPP.git``
|
||||
|
||||
An example can be found [here](https://github.com/jbuberel/buildmodeshared/tree/master/gofromgo).
|
||||
|
||||
## Configuration
|
||||
|
||||
At the installation, the folder ``$XDG_CONFIG_DIRS/http-auth/`` need to be created (example ``/etc/xdg/http-auth``) where to place the configuration file named ``httpAuth.conf``.
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Provide an HTTP authentication over XMPP (https://xmpp.org/extensions/xep-0070.html)
|
||||
|
||||
[Service]
|
||||
ExecStart=/etc/init.d/http-auth.sh start
|
||||
ExecStop=/etc/init.d/http-auth.sh stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
|
||||
#######################
|
||||
name="httpAuth"
|
||||
dirPath="/usr/local/sbin"
|
||||
#######################
|
||||
sh="/bin/bash"
|
||||
pidPath="/var/run/http-auth/http-auth.pid"
|
||||
#######################
|
||||
|
||||
do_start() {
|
||||
nohup $dirPath/$name &
|
||||
/bin/echo $! > $pidPath
|
||||
}
|
||||
|
||||
do_stop() {
|
||||
if [ -e $pidPath ]
|
||||
then
|
||||
pid=$(/bin/cat $pidPath)
|
||||
kill $pid
|
||||
rm $pidPath
|
||||
fi
|
||||
}
|
||||
|
||||
get_status() {
|
||||
if [ -e $pidPath ] ; then
|
||||
pid=$(/bin/cat $pidPath) ;
|
||||
/bin/echo "$name is running with PID $pid" ;
|
||||
else
|
||||
/bin/echo "$name is stopped" ;
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
do_start
|
||||
;;
|
||||
stop)
|
||||
do_stop
|
||||
;;
|
||||
restart)
|
||||
do_stop
|
||||
do_start
|
||||
;;
|
||||
status)
|
||||
get_status
|
||||
;;
|
||||
*)
|
||||
/bin/echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue