Project

General

Profile

« Previous | Next » 

Revision 244

scripts/Makefile: Don't use root as MySQL admin user. Removed no-longer-needed sub-makes for setting DB login vars.

View differences:

Makefile
1
# Make
2
SHELL = /bin/bash
3

  
1 4
# Terminal
2 5
esc = '['
3 6
reset = $(esc)'0m'
4 7
emph = $(esc)'7m '
5
end_emph = ' '$(reset)
6
wait = read -p $(emph)'Press ENTER to continue:'$(end_emph) REPLY
7
done = echo; echo $(emph)"Finished $@"$(end_emph); echo
8
endEmph = ' '$(reset)
9
getPassword = $(shell read -s -p "Enter your $(1) password: " REPLY; \
10
echo >&2; echo "$REPLY")
11
wait = read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY
12
done = echo; echo $(emph)"Finished $@"$(endEmph); echo
8 13

  
9 14
# OS
10 15
os = $(shell uname)
......
27 32

  
28 33
#####
29 34

  
30
with_db = $(MAKE) _with_db_$@
31

  
32
#####
33

  
34 35
install: _not_file core inputs test
35 36
	@$(done)
36 37

  
......
62 63
bienPassword = $(shell cat util/bien_password)
63 64

  
64 65
postgres_user: _not_file
65
	$(with_db)
66
# sub-make will include vegbien_dest
67
_with_db_postgres_user: _not_file
68
	@echo $(emph)"At sudo password prompt, enter *your* password"$(end_emph)
66
	@echo $(emph)"At sudo password prompt, enter *your* password"$(endEmph)
69 67
	@sudo -v
70
	@echo $(emph)"At \"Enter password for new role:\", enter $(bienPassword)"$(end_emph)
68
	@echo $(emph)"At \"Enter password for new role:\", enter $(bienPassword)"$(endEmph)
71 69
	-$($@_cmd)
72 70
# ignore errors about user existing
73
_with_db_postgres_user_cmd = $(asPostgresAdmin) createuser --no-superuser \
71
postgres_user_cmd = $(asPostgresAdmin) createuser --no-superuser \
74 72
--no-createdb --no-createrole --pwprompt "bien"
75 73

  
76 74
rm_postgres_user: _not_file
......
91 89

  
92 90
#####
93 91

  
94
inputs: _not_file $(call forOs,mysql) mysql_user $(wildcard ../../inputs/*/)
92
ifneq ($(filter %_with_mysql_password,$(MAKECMDGOALS)),)
93
mysqlAdminPassword ?= $(call getPassword,MySQL)
94
endif
95

  
96
with_mysql_password = $(MAKE) $@_with_mysql_password
97

  
98
#####
99

  
100
inputs: _not_file
101
	$(with_mysql_password)
102
# use sub-make
103
inputs_with_mysql_password: _not_file $(call forOs,mysql) mysql_user \
104
$(wildcard ../../inputs/*/)
95 105
	@$(done)
96 106

  
97
rm_inputs: _not_file rm_mysql_user
107
rm_inputs: _not_file
108
	$(with_mysql_password)
109
# use sub-make
110
rm_inputs_with_mysql_password: _not_file rm_mysql_user
98 111

  
99 112
mysql-Linux: _not_file
100
	$(with_db)
101
# sub-make will include vegbien_dest
102
_with_db_mysql-Linux: _not_file
103
	@echo $(emph)"At prompt for MySQL root password, enter $(bienPassword)"$(end_emph)
113
	@echo $(emph)"If asked for MySQL root password, enter $(bienPassword)"$(endEmph)
104 114
	@$(wait)
105 115
	-sudo apt-get install mysql-server mysql-client python-mysqldb
106 116

  
107 117
mysql-Darwin: _not_file
108
	@echo $(emph)'Installing MySQLdb Python driver on Mac OS X 10.7 (may work on other versions):'$(end_emph)
118
	@echo $(emph)'Installing MySQLdb Python driver on Mac OS X 10.7 (may work on other versions):'$(endEmph)
109 119
	@echo 'Download it using "latest version" link at http://sourceforge.net/projects/mysql-python/files/'
110 120
	@echo 'Extract the archive'
111 121
	@echo '(From http://www.rustyrazorblade.com/2011/11/installing-mysqldb-on-macos-lion/:)'
......
123 133

  
124 134
mysql-: _not_file # other OSes
125 135

  
126
mysqlAsAdmin = mysql --user=root --password='$(bienPassword)'
136
mysqlAsAdmin = mysql --user='$(USER)' --password='$(mysqlAdminPassword)'
127 137

  
128 138
mysql_user: _not_file
129
	$(with_db)
130
# sub-make will include vegbien_dest
131
_with_db_mysql_user: _not_file
132 139
	-$($@_cmd)
133 140
# ignore errors about user existing
134
_with_db_mysql_user_cmd = echo "CREATE USER 'bien'@'localhost' \
135
IDENTIFIED BY '$(bienPassword)';"|$(mysqlAsAdmin)
141
mysql_user_cmd = echo "CREATE USER 'bien'@'localhost' IDENTIFIED BY \
142
'$(bienPassword)';"|$(mysqlAsAdmin)
136 143

  
137 144
rm_mysql_user: _not_file
138
	$(with_db)
139
# sub-make will include vegbien_dest
140
_with_db_rm_mysql_user: _not_file
141 145
	-echo "DROP USER 'bien'@'localhost';"|$(mysqlAsAdmin)
142 146
# ignore errors about user not existing
143 147

  

Also available in: Unified diff