re='[A-Z/ !@#$%^&*()+~`=]'
if [[ $config =~ $re ]];
then
- echo
+ echo
echo "ERROR: Config name must not contain upper case characters, spaces or special characters. Correct config name and rerun $0."
echo
exit 1
image=discourse/discourse:1.0.15
docker_path=`which docker.io || which docker`
+
if [ "${SUPERVISED}" = "true" ]; then
restart_policy="--restart=no"
attach_on_start="-a"
fi
}
+set_run_image() {
+ run_image=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
+ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['run_image']"`
+
+ if [ -z "$run_image" ]; then
+ run_image="$local_discourse/$config"
+ fi
+}
+
+set_boot_command() {
+ boot_command=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
+ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['boot_command']"`
+
+ if [ -z "$boot_command" ]; then
+
+ no_boot_command=`cat $config_file | $docker_path run $user_args --rm -i -a stdin -a stdout $image ruby -e \
+ "require 'yaml'; puts YAML.load(STDIN.readlines.join)['no_boot_command']"`
+
+ if [ -z "$no_boot_command" ]; then
+ boot_command="/sbin/boot"
+ fi
+ fi
+}
+
run_start(){
existing=`$docker_path ps | awk '{ print $1, $(NF) }' | grep " $config$" | awk '{ print $1 }'`
set_template_info
set_volumes
set_links
+ set_run_image
+ set_boot_command
(
hostname=`hostname`
set -x
$docker_path run $user_args $links $attach_on_run $restart_policy "${env[@]}" -h "$hostname-$config" \
- -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $local_discourse/$config \
- /sbin/boot
+ -e DOCKER_HOST_IP=$docker_ip --name $config -t $ports $volumes $docker_args $run_image $boot_command
)
exit 0
$docker_path rm `cat $cidbootstrap` && rm $cidbootstrap
}
+
+
case "$command" in
bootstrap)
run_bootstrap