Commit 10800d5d authored by Adam Lewenberg's avatar Adam Lewenberg
Browse files

add service file and wrapper

parent ba8def48
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
[Unit]
Description=run the GCP Cloud SQL Proxy service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/cloudsql-proxy.sh

# Restart on any failure after 5 seconds
Restart=on-failure
RestartSec=5s
+33 −0
Original line number Diff line number Diff line
#!/bin/sh

# A wrapper around /usr/bin/cloud_sql_proxy so we can pass options in a
# configuration file.

# Read the configuration file. This file should have the following
# format:
#
# dir=/run/cloudsql
# credential_file=/root/cloudsql.json
# instances=uit-acs-linux:us-west1:acs-linux-mysql-1=tcp:3306
#
# The "instances" option is MANDATORY. The others are OPTIONAL.
#
# These are passed as command line options to /usr/bin/cloud_sql_proxy

. /etc/cloudsql-proxy/options

if [[ -z "$dir" ]]; then
    dir="/run/cloudsql"
fi

if [[ -z "$credential_file" ]]; then
    echo "missing credentials file"
    exit 1
fi

if [[ -z "$instances" ]]; then
    echo "missing instances setting"
    exit 1
fi

/usr/bin/cloud_sql_proxy -dir=$dir -credential_file=$credential_file -instances=$instances

debian/options.example

0 → 100644
+3 −0
Original line number Diff line number Diff line
dir=/run/cloudsql
credential_file=/etc/cloudsql-proxy/cloudsql.json
instances="uit-acs-linux:us-west1:acs-linux-mysql-1=tcp:3306"
+8 −0
Original line number Diff line number Diff line
@@ -10,3 +10,11 @@ DH_VERBOSE=1

%:
	dh $@

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/$(PACKAGE)/usr/bin
	cp $(CURDIR)/debian/cloudsql-proxy.sh debian/$(PACKAGE)/usr/bin/
	#
	mkdir -p debian/$(PACKAGE)/etc/cloudsql-proxy
	cp $(CURDIR)/debian/options.example debian/$(PACKAGE)/etc/cloudsql-proxy
+1 −1

File changed.

Contains only whitespace changes.