Skip to content

Commit ce30fbb

Browse files
committed
Refactor: migrate to systemd and restructure to cmd/ pattern
- Move executables to src/cmd/*/main.go structure - Replace init.d with systemd service - Modernize Go code (remove ioutil, update docopt) - Remove obsolete RPM/Debian build scripts - Update Makefile and postinst for systemd
1 parent db3adef commit ce30fbb

File tree

20 files changed

+193
-729
lines changed

20 files changed

+193
-729
lines changed

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,26 @@ releases:
4646
fi ; \
4747
mkdir $$RELEASE_DIR; \
4848
echo "Building Wigo release for $$target to $$RELEASE_DIR"; \
49-
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o $$RELEASE_DIR/wigo $(BASE_DIR)/src/wigo.go; \
50-
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o $$RELEASE_DIR/wigocli $(BASE_DIR)/src/wigocli.go; \
51-
$(build) -o $$RELEASE_DIR/generate_cert $(BASE_DIR)/src/generate_cert.go; \
49+
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o $$RELEASE_DIR/wigo $(BASE_DIR)/src/cmd/wigo/main.go; \
50+
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o $$RELEASE_DIR/wigocli $(BASE_DIR)/src/cmd/wigocli/main.go; \
51+
$(build) -o $$RELEASE_DIR/generate_cert $(BASE_DIR)/src/cmd/generate_cert/main.go; \
5252
done
5353

5454
release:
5555
@echo "Building Wigo release for current OS"
5656
@mkdir -p release
5757
@cd release; \
5858
export CGO_ENABLED=0; \
59-
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o current/wigo $(BASE_DIR)/src/wigo.go; \
60-
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o current/wigocli $(BASE_DIR)/src/wigocli.go; \
61-
$(build) -o current/generate_cert $(BASE_DIR)/src/generate_cert.go
59+
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o current/wigo $(BASE_DIR)/src/cmd/wigo/main.go; \
60+
$(build) -tags "netgo osusergo" -ldflags "-s -w -X github.com/root-gg/wigo/src/wigo.Version=$(RELEASE_VERSION)" -o current/wigocli $(BASE_DIR)/src/cmd/wigocli/main.go; \
61+
$(build) -o current/generate_cert $(BASE_DIR)/src/cmd/generate_cert/main.go
6262

6363
debs:
6464
@echo "Building Wigo Debian packages"
6565
@mkdir -p $(DEBROOT)
6666
@mkdir -p $(DEBROOT)/etc/wigo/conf.d
6767
@mkdir -p $(DEBROOT)/etc/logrotate.d
68-
@mkdir -p $(DEBROOT)/etc/init.d
68+
@mkdir -p $(DEBROOT)/lib/systemd/system/
6969
@mkdir -p $(DEBROOT)/usr/local/wigo/lib
7070
@mkdir -p $(DEBROOT)/usr/local/wigo/bin
7171
@mkdir -p $(DEBROOT)/usr/local/wigo/etc/conf.d
@@ -80,7 +80,7 @@ debs:
8080
@cp probes/examples/* $(DEBROOT)/usr/local/wigo/probes/examples
8181
@cp etc/wigo.conf $(DEBROOT)/usr/local/wigo/etc/wigo.conf.sample
8282
@cp etc/conf.d/*.conf $(DEBROOT)/usr/local/wigo/etc/conf.d
83-
@cp etc/wigo.init $(DEBROOT)/etc/init.d/wigo && chmod +x $(DEBROOT)/etc/init.d/wigo
83+
@cp etc/wigo.systemd $(DEBROOT)/lib/systemd/system/wigo.service
8484
@cp etc/wigo.logrotate $(DEBROOT)/etc/logrotate.d/wigo
8585
@cp -R public $(DEBROOT)/usr/local/wigo
8686
@sed -i "s/##VERSION##/Wigo v$(RELEASE_VERSION)/" $(DEBROOT)/usr/local/wigo/public/index.html
@@ -94,7 +94,7 @@ debs:
9494
else \
9595
cp release/linux-$$arch/* $(DEBROOT)/usr/local/wigo/bin/ ; \
9696
fi ; \
97-
dpkg-deb -Z xz --build $(DEBROOT) $(DEBROOT)/wigo-$(RELEASE_VERSION)-$$arch.deb ; \
97+
fakeroot dpkg-deb -Z xz --build $(DEBROOT) $(DEBROOT)/wigo-$(RELEASE_VERSION)-$$arch.deb ; \
9898
done
9999

100100
publish-debs:

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,11 @@ make clean releases
108108
```
109109

110110
##### Build debian packages
111-
You will need `reprepro`
111+
You will need `dpkg-deb`
112112
```sh
113113
make debs
114114
```
115115

116-
##### Build rpm packages
117-
You will need rpm-building tools
118-
```sh
119-
cd build/rpm/
120-
./makePackege.sh
121-
```
122-
123116
### Usage
124117

125118
##### Wigo web interface
@@ -130,7 +123,7 @@ cd build/rpm/
130123
##### Wigo CLI
131124

132125
```sh
133-
# wigocli
126+
# /usr/local/wigo/bin/wigocli
134127
Wigo v0.51.5 running on backbone.root.gg
135128
Local Status : 100
136129
Global Status : 250
@@ -153,7 +146,7 @@ Remote Wigos :
153146
Probes are binaries, written in any language you want, that output a json string with at least Status param :
154147
```sh
155148

156-
$ ./hardware_load_average
149+
$ /usr/local/wigo/probes/examples/hardware_load_average
157150
{
158151
"Detail" : "",
159152
"Version" : "0.11",

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.73.32
1+
0.73.33

build/deb/DEBIAN/postinst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ EXAMPLEPROBES300=( smart check_ntp packages-apt )
99
# Fixing logrotate permissions
1010
chown root:root /etc/logrotate.d/wigo
1111

12-
# <TEMPORARY>
13-
rm /etc/wigo/conf.d/smart.conf
14-
# </TEMPORARY>
15-
1612
# Copy config file if not present on system
1713
if [ ! -e /etc/wigo/wigo.conf ] ; then
1814
cp $WIGOPATH/etc/wigo.conf.sample /etc/wigo/wigo.conf
19-
update-rc.d wigo defaults
15+
echo "Config file /etc/wigo/wigo.conf created"
2016
else
2117
echo "Config file /etc/wigo.conf already exists. Not overriding it.."
2218
fi
@@ -30,12 +26,6 @@ for configFile in $CONFIGFILES; do
3026
fi
3127
done
3228

33-
# Retro compatibility
34-
if [ -e /etc/wigo.conf ] ; then
35-
echo "Old config file detected, moving it to /etc/wigo/wigo.conf.."
36-
mv /etc/wigo.conf /etc/wigo/wigo.conf
37-
fi
38-
3929
# Enabling default probes on 60 directory
4030
echo "Enabling default probes.."
4131

@@ -59,6 +49,13 @@ for probeName in ${EXAMPLEPROBES300[@]}; do
5949
fi
6050
done
6151

52+
if [ -f /etc/init.d/wigo ] ; then
53+
/etc/init.d/wigo stop
54+
update-rc.d -f wigo remove
55+
rm -f /etc/init.d/wigo
56+
echo "Old init script removed"
57+
fi
6258

59+
echo "Starting Wigo service"
6360
# Start it
64-
/etc/init.d/wigo restart
61+
systemctl daemon-reload && systemctl enable wigo && systemctl restart wigo

build/deb/makePackage.sh

Lines changed: 0 additions & 140 deletions
This file was deleted.

build/rpm/makePackege.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)