Commit 1ef13107 authored by James Coyle's avatar James Coyle

Various fixes

parent f4a00dd0
......@@ -5,13 +5,13 @@ Description=Cockroach db
WantedBy=multi-user.target
[Service]
ExecStartPre=/bin/bash -c "[[ -f /etc/cockroachdb/hosts ]] && (/bin/systemctl set-environment JOIN_SWITCH="--join="$(cat /etc/cockroachdb/hosts))"
ExecStartPre=/bin/bash -c "test -f /etc/cockroachdb/hosts && (/bin/systemctl set-environment JOIN_SWITCH=--join=$(test -f /etc/cockroachdb/hosts && cat /dev/null /etc/cockroachdb/hosts)) || exit 0"
ExecStart=/usr/local/bin/cockroach start --certs-dir=/etc/cockroachdb/certs \
--store=/var/data/cockroachdb/ \
--cache=.40 \
--max-sql-memory=.30 \
--external-io-dir=/tmp/cockroachdb/externalio \
--temp-dir=/tmp/cockroachdb/tmp \
--temp-dir=/tmp/ \
--port=26257 \
--http-port=7005 \
--logtostderr=ERROR \
......@@ -24,4 +24,4 @@ Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
LimitNOFILE=35000
LimitNOFILE=35000
\ No newline at end of file
......@@ -6,37 +6,37 @@ DATA_DIR="/var/data/cockroachdb"
ETC="/etc/cockroachdb"
CERT_DIR="$ETC/certs"
CERT_PRIVATE_DIR="$CERT_DIR/private"
TMP=/tmp/cockroachdb.rgz
TMP_DL=/tmp/cockroachdb.tgz
TMP=/tmp
set -e
function usage {
# Not used but kept for doco
printf "Cockroachdb Installer\nUsage: $1 [user]\n"
# Not used but kept for doco
printf "Cockroachdb Installer\nUsage: $1 [user]\n"
}
function getBin{
wget -O $TMP https://binaries.cockroachdb.com/cockroach-latest.linux-amd64.tgz
function getBin {
wget -O $TMP_DL https://binaries.cockroachdb.com/cockroach-latest.linux-amd64.tgz
}
function extractRoach {
mkdir -p "$APP_DIR" || exit 1
tar -xzf "$1" || exit 1
mkdir -p "$APP_DIR" || exit 1
tar -xzf $TMP_DL -C $TMP || exit 1
}
function setInstallDirs {
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
mv -f "$filename/cockroach" "$APP_DIR/cockroach" || exit 1
rm -rf "$filename"
mkdir -p "$DATA_DIR" || exit 1
mv $TMP/cockroach-latest*/cockroach $APP_DIR/cockroach || exit 1
rm -rf $TMP/cockroach-latest*
mkdir -p "$DATA_DIR" || exit 1
}
function installCerts {
mkdir -p "$CERT_DIR" || exit 1
mkdir -p "$CERT_PRIVATE_DIR" || exit 1
"$APP_DIR/cockroach" cert create-ca --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
"$APP_DIR/cockroach" cert create-client root --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
"$APP_DIR/cockroach" cert create-node localhost $(hostname) --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
"$APP_DIR/cockroach" cert create-ca --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
"$APP_DIR/cockroach" cert create-client root --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
"$APP_DIR/cockroach" cert create-node localhost $(hostname) --certs-dir="$CERT_DIR" --ca-key="$CERT_PRIVATE_DIR/ca.key" || exit 1
}
function changePerms {
......@@ -48,9 +48,9 @@ function changePerms {
}
function installService {
mkdir -p "$SYSTEMD_DIR" || exit 1
cp -f cockroach.service "$SYSTEMD_DIR" || exit 1
systemctl enable cockroach.service || exit 1
mkdir -p "$SYSTEMD_DIR" || exit 1
cp -f cockroach.service "$SYSTEMD_DIR" || exit 1
systemctl enable cockroach.service || exit 1
}
#create cconnect script for easier access to the sql console
......@@ -66,15 +66,15 @@ function outputConnectUtil {
echo "Installing..."
getBin
extractRoach $TMP
setInstallDirs $TMP
extractRoach $TMP_DL
setInstallDirs $TMP_DL
installCerts
changePerms $1
installService
outputConnectUtil
rm $TMP
rm $TMP_DL
echo "Done!"
exit 0
exit 0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment