fix: [installer] if not installed as a user other then 'misp' we used to fail, now fixed

pull/6630/head
Steve Clement 2020-11-20 16:57:33 +09:00
parent 63640c011e
commit cacfb6ec38
No known key found for this signature in database
GPG Key ID: 69A20F509BE4AEE9
2 changed files with 12 additions and 3 deletions

View File

@ -264,7 +264,7 @@ prepareDB () {
if [[ ! -e /var/lib/mysql/misp/users.ibd ]]; then
debug "Setting up database"
# FIXME: If user 'misp' exists, and has a different password, the below WILL fail.
# FIXME: If user 'misp' exists, and has a different password, the below WILL fail. Partially fixed with the Env-Var check in the beginning. (Need to implement pre-flight checks to exit gracefully if not set)
# Add your credentials if needed, if sudo has NOPASS, comment out the relevant lines
if [[ "${PACKER}" == "1" ]]; then
pw="Password1234"
@ -272,10 +272,18 @@ prepareDB () {
pw=${MISP_PASSWORD}
fi
if [[ ! -z ${INSTALL_USER} ]]; then
SUDO_EXPECT="sudo mysql_secure_installation"
echo "Making sure sudo session is buffered"
sudo ls -la /tmp > /dev/null 2> /dev/null
else
SUDO_EXPECT="sudo -k mysql_secure_installation"
fi
expect -f - <<-EOF
set timeout 10
spawn sudo -k mysql_secure_installation
spawn ${SUDO_EXPECT}
expect "*?assword*"
send -- "${pw}\r"
expect "Enter current password for root (enter for none):"

View File

@ -373,10 +373,11 @@ checkID () {
clean > /dev/null 2>&1
exit 1
elif [[ $(id $MISP_USER >/dev/null; echo $?) -ne 0 ]]; then
if [[ "$UNATTENDED" != "1" ]]; then
if [[ "$UNATTENDED" != "1" ]]; then
echo "There is NO user called '$MISP_USER' create a user '$MISP_USER' (y) or continue as $USER (n)? (y/n) "
read ANSWER
ANSWER=$(echo $ANSWER |tr '[:upper:]' '[:lower:]')
INSTALL_USER=${USER}
else
ANSWER="y"
fi