Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete the automatic (cli) install process #278

Closed
wants to merge 10 commits into from
16 changes: 16 additions & 0 deletions 2025.02-dev/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
install=true
m33m33 marked this conversation as resolved.
Show resolved Hide resolved
else
echo "One or more environment variable is not set, skipping automated installation"
fi

if [ "$install" = true ]; then
Expand All @@ -165,6 +168,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
rsync $rsync_options --ignore-existing /usr/src/friendica/config/ /var/www/html/config/
fi

# Add the administrator account
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the idea of creating the admin account with the --admin parameter in the install_options? I'm not sure if it doesn't work with the install_options but to me it looks suspicious to have this on two places.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t know about install_options, this patch simply mimics the command lines calling console user/password.

Copy link
Collaborator

@ne20002 ne20002 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refer to the lines with the friendica install in lines 158,159.

echo "Starting Friendica installation ..."
run_as "php /var/www/html/bin/console.php autoinstall $install_options"

Within the install_options there is the --admin parameter with
--admin "'$FRIENDICA_ADMIN_MAIL'"

I believe this is for creating the admin account so I wonder why you see a need to add it afterwards.
But I have no deeper knowledge of what autoinstall does.

I also wonder if the problem with the creating of the admin account is a docker image problem only or if this also applies to plain installation. In this case the fix should be in the autoinstall implementation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within the install_options there is the --admin parameter with
--admin "'$FRIENDICA_ADMIN_MAIL'"

I will have a look at what this does if I can

I also wonder if the problem with the creating of the admin account is a docker image problem only or if this also applies to plain installation. In this case the fix should be in the autoinstall implementation.

At this time with stable release: the WebUI wizard is also stuck in a loop on my system (you go through all the 3 config screen then blank page, refresh and you go again). This is why I abandoned it and went for the command line only.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it seems it only collects the administrator's email and put it in the configuration file :

Console.php => AutomaticInstallation.php => Installer.php and you see it here in createConfig()

Copy link
Author

@m33m33 m33m33 Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too have a very limited understanding of Friendica internals, like 5%.

My point is installing a new instance now 80% of the time would be in a docker container, and it must gives a functional instance right away, otherwise it's an early disapointment and they are so many turnkey options to choose (I'm trying Sharkey next to Friendica because I used to host a Misskey-Foundkey instance, firing up a dockerized Sharkey instance is a no brainer: 2 mins and you're up). I think Friendica's installation process should make reasonable assumptions and go full automatic like that (and of course for experienced admins have a manual way to install). I understand that Friendica is trying hard to be compatible with many environments, from a managed LAMP stack to docker or bare metal fully manual install, that's a good thing since I don't know many other Fediverse instances that can do that, no critics here, just trying to get beginer admins like me a push to get in the saddle ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thank you for digging into it.

Having the cli install working and the web install not seems to be better than having none of them working. But I still wonder why the web install is not working and if there is a common reason.

changeme=`head -c 30 /dev/urandom | base64`
FRIENDICA_ADMIN_NICKNAME=`echo $FRIENDICA_ADMIN_MAIL | sed 's/@.*//'`
echo " "
echo "Adding the administrator account named: $FRIENDICA_ADMIN_NICKNAME"
run_as "php /var/www/html/bin/console.php user add $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_MAIL EN $FRIENDICA_URL/images/person-300.jpg"
echo "Setting password"
run_as "php /var/www/html/bin/console.php user password $FRIENDICA_ADMIN_NICKNAME $changeme"
echo " "
echo "YOUR ADMINISTRATOR PASSWORD IS: $changeme"
echo "NOTE IT DOWN AND CHANGE IT ON FIRST LOGIN"
echo " "
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
Expand All @@ -178,6 +193,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
run_as 'php /var/www/html/bin/console.php dbstructure update -f'
echo "Upgrading finished"
fi

m33m33 marked this conversation as resolved.
Show resolved Hide resolved
fi
) 9> /var/www/html/friendica-init-sync.lock
fi
Expand Down
16 changes: 16 additions & 0 deletions 2025.02-dev/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
install=true
m33m33 marked this conversation as resolved.
Show resolved Hide resolved
else
echo "One or more environment variable is not set, skipping automated installation"
fi

if [ "$install" = true ]; then
Expand All @@ -165,6 +168,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
rsync $rsync_options --ignore-existing /usr/src/friendica/config/ /var/www/html/config/
fi

# Add the administrator account
ne20002 marked this conversation as resolved.
Show resolved Hide resolved
changeme=`head -c 30 /dev/urandom | base64`
FRIENDICA_ADMIN_NICKNAME=`echo $FRIENDICA_ADMIN_MAIL | sed 's/@.*//'`
echo " "
echo "Adding the administrator account named: $FRIENDICA_ADMIN_NICKNAME"
run_as "php /var/www/html/bin/console.php user add $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_MAIL EN $FRIENDICA_URL/images/person-300.jpg"
echo "Setting password"
run_as "php /var/www/html/bin/console.php user password $FRIENDICA_ADMIN_NICKNAME $changeme"
echo " "
echo "YOUR ADMINISTRATOR PASSWORD IS: $changeme"
echo "NOTE IT DOWN AND CHANGE IT ON FIRST LOGIN"
echo " "
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
Expand All @@ -178,6 +193,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
run_as 'php /var/www/html/bin/console.php dbstructure update -f'
echo "Upgrading finished"
fi

m33m33 marked this conversation as resolved.
Show resolved Hide resolved
fi
) 9> /var/www/html/friendica-init-sync.lock
fi
Expand Down
16 changes: 16 additions & 0 deletions 2025.02-dev/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
# shellcheck disable=SC2016
install_options=$install_options' --admin "'$FRIENDICA_ADMIN_MAIL'" --tz "'$FRIENDICA_TZ'" --lang "'$FRIENDICA_LANG'" --url "'$FRIENDICA_URL'"'
install=true
install=true
m33m33 marked this conversation as resolved.
Show resolved Hide resolved
else
echo "One or more environment variable is not set, skipping automated installation"
fi

if [ "$install" = true ]; then
Expand All @@ -165,6 +168,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
rsync $rsync_options --ignore-existing /usr/src/friendica/config/ /var/www/html/config/
fi

# Add the administrator account
ne20002 marked this conversation as resolved.
Show resolved Hide resolved
changeme=`head -c 30 /dev/urandom | base64`
FRIENDICA_ADMIN_NICKNAME=`echo $FRIENDICA_ADMIN_MAIL | sed 's/@.*//'`
echo " "
echo "Adding the administrator account named: $FRIENDICA_ADMIN_NICKNAME"
run_as "php /var/www/html/bin/console.php user add $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_NICKNAME $FRIENDICA_ADMIN_MAIL EN $FRIENDICA_URL/images/person-300.jpg"
echo "Setting password"
run_as "php /var/www/html/bin/console.php user password $FRIENDICA_ADMIN_NICKNAME $changeme"
echo " "
echo "YOUR ADMINISTRATOR PASSWORD IS: $changeme"
echo "NOTE IT DOWN AND CHANGE IT ON FIRST LOGIN"
echo " "
echo "Installation finished"
else
echo "[ERROR] Waited 300 seconds, no response" >&2
Expand All @@ -178,6 +193,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ]; then
run_as 'php /var/www/html/bin/console.php dbstructure update -f'
echo "Upgrading finished"
fi

m33m33 marked this conversation as resolved.
Show resolved Hide resolved
fi
) 9> /var/www/html/friendica-init-sync.lock
fi
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Note that you may have to change other limits depending on your client, webserve

## Administrator account

Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `MAILNAME`.
Because Friendica links the administrator account to a specific mail address, you **have** to set a valid address for `FRIENDICA_ADMIN_MAIL`.

## Mail settings

Expand Down Expand Up @@ -180,6 +180,9 @@ To enable the automatic installation, you have to the following environment vari
- `MYSQL_DATABASE` Name of the database using mysql / mariadb.
- `MYSQL_HOST` Hostname of the database server using mysql / mariadb.

**During the first run, you will be given the `FRIENDICA_ADMIN_MAIL` administrator's account first random password.**
**It is important to note it down and change it after first login.**

# Docker Secrets
As an alternative to passing sensitive information via environment variables, _FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container.
In particular, this can be used to load passwords from Docker secrets stored in /run/secrets/<secret_name> files.
Expand Down