Skip to content

Commit

Permalink
Simpler build scripts (#1964)
Browse files Browse the repository at this point in the history
* feat: Add logrotate script and update log location

Write to /var/log/proxysql.log by default, and add a logrotate script
which manages this path.

Unfortunately, the logrotate script can't use `PROXYSQL FLUSH LOGS;` to
tell ProxySQL to rotate file handles*, so we use copytruncate instead.
It would be nice if ProxySQL could rotate file handles following a
signal in future...

* For two reasons:
1. There's no safe / standard way to find admin credentials
2. mysql(1) client may not be installed

* fix: Better handle unknown OS service un/install

This adds an error message to `make install/uninstall` on "unsupported"
distros. The behaviour is the same as before (do nothing, successfully).

* fix: Unify standard, debug and clickhouse build scripts

The build scripts for all three packaging targets are identical except
for their Make targets. Unify them, and pass in a new environment
variable PROXYSQL_BUILD_TYPE to define the build type we want.

The build scripts are updated to automatically exit if any command fails
(`set -e`), so the "&& \" pattern is no longer required. We also
`set -u` to protect against any variable being accidentally unset.

* fix: Simplify build script logic

We don't need the `&& \` pattern any more now that `set -e` is defined
at the top of the script. Also apply several defensive fixes suggested
by the Shellcheck linter (https://github.com/koalaman/shellcheck).

* fix: Add missing directory to cleanup

* fix: cosmetics

* fix: Don't define config file twice
  • Loading branch information
alexjurkiewicz authored and Nick Vyzas committed Mar 20, 2019
1 parent ee219f4 commit 39a0c9c
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 137 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ DEBUG=${ALL_DEBUG}
export MAKE
export CURVER?=2.0.3
export MAKEOPT=-j 4
DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release)
ifneq (,$(wildcard /etc/os-release))
DISTRO := $(shell gawk -F= '/^NAME/{print $$2}' /etc/os-release)
else
DISTRO := unknown
endif
ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system)
SYSTEMD=1
else
Expand Down Expand Up @@ -373,6 +377,10 @@ ifeq ($(DISTRO),"Ubuntu")
else
ifeq ($(DISTRO),"Debian GNU/Linux")
update-rc.d proxysql defaults
else
ifeq ($(DISTRO),"Unknown")
$(warning Not sure how to install proxysql service on this OS)
endif
endif
endif
endif
Expand Down Expand Up @@ -405,6 +413,10 @@ else
ifeq ($(DISTRO),"Debian GNU/Linux")
if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi
update-rc.d proxysql remove
else
ifeq ($(DISTRO),"Unknown")
$(warning Not sure how to uninstall proxysql service on this OS)
endif
endif
endif
endif
Expand Down
66 changes: 44 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ services:
image: proxysql/packaging:build-centos5
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-centos5
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
centos67_build:
Expand All @@ -43,13 +44,14 @@ services:
image: proxysql/packaging:build-centos6.7
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-centos67
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
centos7_build:
Expand All @@ -69,26 +71,28 @@ services:
image: proxysql/packaging:build-centos7
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-centos7
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
centos7_ch_build:
image: proxysql/packaging:build-centos7
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-centos7
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
fedora24_build:
Expand All @@ -108,26 +112,28 @@ services:
image: proxysql/packaging:build-fedora24
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-fedora24
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
fedora24_ch_build:
image: proxysql/packaging:build-fedora24
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-fedora24
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
fedora27_build:
Expand All @@ -147,26 +153,28 @@ services:
image: proxysql/packaging:build-fedora27
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-fedora27
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
fedora27_ch_build:
image: proxysql/packaging:build-fedora27
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-fedora27
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
fedora28_build:
Expand All @@ -186,26 +194,28 @@ services:
image: proxysql/packaging:build-fedora28
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-fedora28
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
fedora28_ch_build:
image: proxysql/packaging:build-fedora28
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/:/root/
- ./docker/images/proxysql/rhel-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-fedora28
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
debian7_build:
Expand All @@ -225,13 +235,14 @@ services:
image: proxysql/packaging:build-debian7
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-debian7
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
debian8_build:
Expand All @@ -251,13 +262,14 @@ services:
image: proxysql/packaging:build-debian8
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-debian8
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
debian9_build:
Expand All @@ -277,26 +289,28 @@ services:
image: proxysql/packaging:build-debian9
volumes:
- ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-debian9
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
debian9_ch_build:
image: proxysql/packaging:build-debian9
volumes:
- ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-debian9
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
debian9.4_build:
Expand All @@ -316,26 +330,28 @@ services:
image: proxysql/packaging:build-debian9.4
volumes:
- ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-debian9.4
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
debian9.4_ch_build:
image: proxysql/packaging:build-debian9.4
volumes:
- ./docker/images/proxysql/deb-compliant/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-debian9.4
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
ubuntu12_build:
Expand All @@ -355,13 +371,14 @@ services:
image: proxysql/packaging:build-ubuntu12
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-ubuntu12
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
ubuntu14_build:
Expand All @@ -381,13 +398,14 @@ services:
image: proxysql/packaging:build-ubuntu14
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-ubuntu14
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
ubuntu16_build:
Expand All @@ -407,26 +425,28 @@ services:
image: proxysql/packaging:build-ubuntu16
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-ubuntu16
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
ubuntu16_ch_build:
image: proxysql/packaging:build-ubuntu16
volumes:
- ./docker/images/proxysql/deb-compliant/pre-systemd/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-ubuntu16
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
ubuntu18_build:
Expand All @@ -446,25 +466,27 @@ services:
image: proxysql/packaging:build-ubuntu18
volumes:
- ./docker/images/proxysql/deb-compliant/bionic-package/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/dbg-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=dbg-ubuntu18
- PROXYSQL_BUILD_TYPE=debug
command:
- /opt/entrypoint/entrypoint.bash
ubuntu18_ch_build:
image: proxysql/packaging:build-ubuntu18
volumes:
- ./docker/images/proxysql/deb-compliant/bionic-package/ctl/:/root/ctl/
- ./docker/images/proxysql/deb-compliant/ch-entrypoint/:/opt/entrypoint/
- ./docker/images/proxysql/deb-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- MAKE
- MAKEOPT
- CURVER
- PKG_RELEASE=clickhouse-ubuntu18
- PROXYSQL_BUILD_TYPE=clickhouse
command:
- /opt/entrypoint/entrypoint.bash
18 changes: 0 additions & 18 deletions docker/images/proxysql/deb-compliant/ch-entrypoint/entrypoint.bash

This file was deleted.

Loading

0 comments on commit 39a0c9c

Please sign in to comment.