Skip to content

Commit

Permalink
Show message if people didn't run dev setup
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenBoersma committed Jul 31, 2018
1 parent 8b7f198 commit 3d3e153
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 3 additions & 3 deletions bin/dev_command/build
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

cd ${DEV_DIR};

if [ -n "$@" ]; then
services="$@";
if [ -n "$*" ]; then
services="$*";
else
services=`./${DEV_SELF} config --services`;
fi
Expand All @@ -19,7 +19,7 @@ fi

dc yml_all;
dc mode build;
dc cmd "${userarg} ${grouparg} $@";
dc cmd "${userarg} ${grouparg}"

for a in ${services}; do
cmd="`dc show` $a";
Expand Down
18 changes: 12 additions & 6 deletions bin/dev_command/setup
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,25 @@ setup() {

echo 'Starting regular database user, waiting for db to become ready';
./${DEV_SELF} up db;
./${DEV_SELF} logs -f db 2>&1 | grep -m1 'ready for connections';
while true; do
./${DEV_SELF} logs db 2>&1 | grep 'port: 3306 Percona' > /dev/null && break;
echo -n '.';
sleep 1;
done
echo '';

local user=${USER};

# Check if already exists
echo "select * from mysql.user where user='${user}';" | dev myroot | grep "${user}" >/dev/null && return 1;
echo "select * from mysql.user where user='${user}';" | dev myroot 2>/dev/null| grep "${user}" >/dev/null && return 1;

echo 'Database user has access to databases "'${user}'_*"';
echo '';
echo "create user '${user}'" | ./${DEV_SELF} myroot;
echo "grant all on ${user}.* to '${user}'" | ./${DEV_SELF} myroot;
echo "update mysql.db set db = '${user}\_%' where user = '${user}';" | ./${DEV_SELF} myroot;
echo 'flush privileges;' | ./${DEV_SELF} myroot;
echo "\
create user '${user}';\
grant all on ${user}.* to '${user}';\
update mysql.db set db = '${user}\_%' where user = '${user}';\
flush privileges;" | ./${DEV_SELF} myroot 2>/dev/null;

return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions bin/dev_command/up
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

if [ -z "`docker volume ls -q -f 'name=dockerdev-mysql-volume'`" ]; then
echo 'No MySQL volume file found, first time here? Run "bin/dev setup" to setup the most important stuff';
exit 1;
fi


if [ -z "${DOMAINSUFFIX}" ]; then
dc yml build/dist/docker-compose-suffix.yml;
Expand Down

0 comments on commit 3d3e153

Please sign in to comment.