Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardise shebang and add MariaDB #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Managing a Semaphore project's dependency cache files

Expand Down
2 changes: 1 addition & 1 deletion install-package
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Package installer with caching, version 2.2

show_usage_and_exit() {
Expand Down
2 changes: 1 addition & 1 deletion release/create_release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion retry
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copied from: https://raw.githubusercontent.com/renderedtext/scripts/8f67b78cef7f5a7556777f59a5f290db8b23abe1/utility/retry
#
Expand Down
Empty file modified sem-dockerize
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion sem-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
SEMAPHORE_PACKAGE_REPOSITORY="http://packages.semaphoreci.com"
install::available() {
response=$(curl --write-out %{http_code} --head --silent --output /dev/null $SEMAPHORE_PACKAGE_REPOSITORY/${language}/${language_version}.tar.gz)
Expand Down
31 changes: 30 additions & 1 deletion sem-service
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Misc
DATE_FORMAT='%H:%M %d/%m/%Y'
Expand All @@ -8,6 +8,7 @@ state=('success' 'fail')
download_location='local'
declare -A sem_services
sem_services['memcached']="1.5 1.6"
#sem_services['mariadb']="10.1.48 10.1 10.2.36 10.2 10.3.27 10.3 10.4.17 10.4 10.5.8 10.5 10"
sem_services['mysql']="5.5 5.6.52 5.6 5.6.50 5.7.13 5.7.25 5.7.27 5.7.31 5.7.32 5.7 5 8.0.16 8.0.22 8.0 8"
sem_services['redis']="2.8.23 2.8 2 3.2.4 3.2.12 3.2 3 4.0.12 4.0.14 4.0 4 5.0.6 5.0.9 5.0 5 6.0.5 6.0.8 6.0 6"
sem_services['mongo']="3.2.1 3.2 3.6.20 3.6 3 4.0.20 4.0 4.1.13 4.1 4.2.10 4.2 4.4.1 4.4 4"
Expand Down Expand Up @@ -74,6 +75,26 @@ service::check_version(){
fi
}

service::start_mariadb() {
service_version=$1
shift
local service_image=''

docker_params="$@"
service::pull_image "$service_image:$service_version"
docker_output=$(docker run $docker_params $service_image:$service_version)
# run only if previous command exited successfully
docker_status=$(sem-dockerize 3306 mariadb)
if [ "$docker_status" == "0" ]; then
echo "done."
echo "MariaDB $service_version is running at 0.0.0.0:3306"
echo "To access it use username 'root' and blank password."
else
# if not started in 30 seconds print logs and exit
echo "$docker_output"
fi
}

service::start_mysql() {
service_version=$1
shift
Expand Down Expand Up @@ -248,6 +269,13 @@ service::start() {
echo -n "Starting $service_name..."

case "$service_name" in
"mariadb" )
shift
service_version=$(sem-service-check-params mariadb $@)
service::check_version 'mariadb' ${service_version%% *}
service::duration service::start_mariadb $service_version total $service_name
exit 0
;;
"mysql" )
shift
service_version=$(sem-service-check-params mysql $@)
Expand Down Expand Up @@ -439,6 +467,7 @@ service::print_usage() {
echo -e "\nsem-service [start|stop|status] [service] [version]\n"

echo "Available services:"
echo "mariadb (default: 10.5), available versions: ${sem_services['mariadb']}"
echo "mysql (default: 5.6), available versions: ${sem_services['mysql']}"
echo "postgres (default: 9.6), available versions: ${sem_services['postgres']}"
echo "redis (default: 4.0), available versions: ${sem_services['redis']}"
Expand Down
40 changes: 40 additions & 0 deletions sem-service-check-params
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
#!/usr/bin/env bash

params-check::mariadb () {
default_params='--net=host --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -v /var/tmp/mysql:/var/lib/mysql --name mariadb -v /var/run/mysqld:/var/run/mysqld '
service_version="10.5"
sudo mkdir -p /var/run/mysqld ; sudo chmod -R 0777 /var/run/mysqld
sudo mkdir -p /var/tmp/mysqld ; sudo chmod -R 0777 /var/tmp/mysqld
params=""
if [ "${1:0:1}" == "-" ];then
params="$@"
else
service_version="${1:-$service_version}"
tmp="${@:2}"
params="${tmp:-$default_params}"
fi
if [ "$default_params" != "$params" ];then
username=""; password=""; db=" -e MYSQL_DATABASE="; dbname="";
for words in $params; do
case $words in
--username=* )
username=" -e MYSQL_USER=$(echo $words|cut -d'=' -f2) "
;;
--password=* )
password=" -e MYSQL_PASSWORD=$(echo $words|cut -d'=' -f2) "
;;
--db=* )
dbname=$(echo $words|cut -d'=' -f2)
;;
*)
;;
esac
done
dbname=${dbname:-'test'}
[ "$username$password" ] && default_params="$default_params$username$password$db$dbname "
fi
echo "$service_version $default_params"
}

params-check::mysql () {
default_params='--net=host --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -v /var/tmp/mysql:/var/lib/mysql --name mysql -v /var/run/mysqld:/var/run/mysqld '
service_version="5.6"
Expand Down Expand Up @@ -123,6 +159,10 @@ params-check::mongodb () {

params-check::main () {
case "$1" in
"mariadb" )
shift
params-check::mariadb $@
;;
"mysql" )
shift
params-check::mysql $@
Expand Down
2 changes: 1 addition & 1 deletion sem-version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
source ~/.toolbox/sem-install

# Changing language versions
Expand Down
Empty file modified ssh-session-cli
100644 → 100755
Empty file.