|
| |
39 |
39 |
|
|
| |
40 |
40 |
db_get dotlrn/dbu_password |
|
| |
41 |
41 |
dbu_password="$RET" |
|
| |
|
42 |
|
|
| |
|
43 |
db_get dotlrn/pg_grant_access |
|
| |
|
44 |
if [ ! -z "$RET" ]; then |
|
| |
|
45 |
grant_access="$RET" |
|
| |
|
46 |
else |
|
| |
|
47 |
grant_access="false" |
|
| |
|
48 |
fi |
|
| |
42 |
49 |
} |
|
| |
43 |
50 |
|
|
| |
44 |
51 |
db_not_installed() { |
|
|
| |
85 |
92 |
dbadmin=$dba_name |
|
| |
86 |
93 |
dbadmpass=$dba_password |
|
| |
87 |
94 |
dbuser=$dbu_name |
|
| |
88 |
|
dbpass=$dbu_password |
|
| |
|
95 |
dbpass=$dbu_password |
|
| |
89 |
96 |
|
|
| |
90 |
97 |
. /usr/share/wwwconfig-common/pgsql-createuser.sh |
|
| |
91 |
98 |
if [ "$status" = "error" ] |
|
|
| |
100 |
107 |
echo $error |
|
| |
101 |
108 |
fi |
|
| |
102 |
109 |
|
|
| |
|
110 |
# Modify the pg_hba.conf to grant dotlrn user access to postgresql |
|
| |
|
111 |
# 1- Do we want to do that? |
|
| |
|
112 |
if [ "$grant_access" = true ]; then |
|
| |
|
113 |
|
|
| |
|
114 |
# 2- Where is the pg_hba.conf from this database instance? |
|
| |
|
115 |
dbuser=$dba_name |
|
| |
|
116 |
dbpass=$dba_password |
|
| |
|
117 |
. /usr/share/wwwconfig-common/pgsql.get |
|
| |
|
118 |
pg_hba_file=$($pgsqlcmd -c "SELECT * from pg_settings where name='hba_file';" 2>/dev/null | grep hba | cut -d\| -f2) |
|
| |
|
119 |
pg_version=$(echo "$pg_hba_file" | cut -d\/ -f4) |
|
| |
|
120 |
if [ "$status" = "error" ] |
|
| |
|
121 |
then |
|
| |
|
122 |
err=1 |
|
| |
|
123 |
echo $error |
|
| |
|
124 |
else |
|
| |
|
125 |
# 3- Modify the file |
|
| |
|
126 |
# Select connection method |
|
| |
|
127 |
if [ "A$dbu_password" != "A" ]; then |
|
| |
|
128 |
# No Blank Password |
|
| |
|
129 |
pg_conn_method="md5" |
|
| |
|
130 |
else |
|
| |
|
131 |
# Blank Password |
|
| |
|
132 |
pg_conn_method="trust" |
|
| |
|
133 |
fi |
|
| |
|
134 |
# Delete all lines between ## dotLRN ... ## and ########### from previous configurations. |
|
| |
|
135 |
# Insert connection line after the first local connection line (the postgres user connection line). |
|
| |
|
136 |
sed -i "/^## dotLRN package debconf changes (DO NOT EDIT BYHAND) ##/,/^#########################################################/d;1,/^local/{ |
|
| |
|
137 |
/^local/a ## dotLRN package debconf changes (DO NOT EDIT BYHAND) ##\nlocal dotlrn $dbu_name $pg_conn_method\n######################################################### |
|
| |
|
138 |
} " $pg_hba_file |
|
| |
|
139 |
|
|
| |
|
140 |
# 4-Reload postgresql conf |
|
| |
|
141 |
/etc/init.d/postgresql-"$pg_version" reload |
|
| |
|
142 |
fi |
|
| |
|
143 |
fi |
|
| |
|
144 |
|
|
| |
103 |
145 |
# Modify config.tcl with debconf values |
|
| |
104 |
|
|
|
| |
|
146 |
dbuser=$dbu_name |
|
| |
|
147 |
dbpass=$dbu_password |
|
| |
105 |
148 |
sed -i "/^ set db_host/,/^ set db_user/d;s/## Debconf changes (DO NOT EDIT BYHAND) ##/&\n set db_host $dbserver\n set db_password \"$dbpass\"\n set db_port \"5432\"\n set db_user $dbuser/" /etc/dotlrn/config.tcl |
|
| |
106 |
149 |
|
|
| |
107 |
150 |
# Install plpgsql on database and enable compatibility options |