|
171 | 171 | ssh $SSH_OPTS "$REMOTE_USER@$REMOTE_HOST" "chown -R tomcat:tomcat /opt/tomcat/webapps/${TOMCAT_CONTEXT}* && systemctl restart tomcat" |
172 | 172 | echo "[*] Tomcat restarted with new deployment" |
173 | 173 |
|
| 174 | +# ─── Ensure db.properties on remote for JSP pages ─── |
| 175 | +echo "[*] Configuring database credentials for JSP pages..." |
| 176 | +DB_PROPS_LOCAL="$WEBAPP_SRC/WEB-INF/db.properties" |
| 177 | +DB_PROPS_REMOTE="/opt/tomcat/webapps/${TOMCAT_CONTEXT}/WEB-INF/db.properties" |
| 178 | + |
| 179 | +if [ -f "$DB_PROPS_LOCAL" ]; then |
| 180 | + scp -o ConnectTimeout=10 -o BatchMode=yes "$DB_PROPS_LOCAL" "$REMOTE_USER@$REMOTE_HOST:$DB_PROPS_REMOTE" |
| 181 | +else |
| 182 | + # Prompt for remote DB credentials |
| 183 | + echo " JSP pages need MySQL credentials on the remote server." |
| 184 | + read -rp " Remote MySQL username [root]: " R_DB_USER |
| 185 | + R_DB_USER="${R_DB_USER:-root}" |
| 186 | + read -rsp " Remote MySQL password: " R_DB_PASS |
| 187 | + echo "" |
| 188 | + read -rp " Remote MySQL host [localhost]: " R_DB_HOST |
| 189 | + R_DB_HOST="${R_DB_HOST:-localhost}" |
| 190 | + read -rp " Remote MySQL port [3306]: " R_DB_PORT |
| 191 | + R_DB_PORT="${R_DB_PORT:-3306}" |
| 192 | + |
| 193 | + ssh $SSH_OPTS "$REMOTE_USER@$REMOTE_HOST" "cat > $DB_PROPS_REMOTE <<'DBEOF' |
| 194 | +# BMA Database Configuration — written by deploy script |
| 195 | +db.driver=com.mysql.cj.jdbc.Driver |
| 196 | +db.url=jdbc:mysql://${R_DB_HOST}:${R_DB_PORT}/BrarnerScience |
| 197 | +db.user=${R_DB_USER} |
| 198 | +db.password=${R_DB_PASS} |
| 199 | +DBEOF |
| 200 | +" |
| 201 | +fi |
| 202 | +ssh $SSH_OPTS "$REMOTE_USER@$REMOTE_HOST" "chmod 600 $DB_PROPS_REMOTE && chown tomcat:tomcat $DB_PROPS_REMOTE" |
| 203 | +echo "[✓] db.properties configured for JSP database access" |
| 204 | + |
174 | 205 | # ─── Deploy static copy for Apache (images served directly) ─── |
175 | 206 | echo "[*] Deploying static assets to ${REMOTE_PATH}..." |
176 | 207 | ssh $SSH_OPTS "$REMOTE_USER@$REMOTE_HOST" "mkdir -p ${REMOTE_PATH}/{images,css}" |
|
0 commit comments