Create admin account on our own as it was removed upstream

This commit is contained in:
Johannes Zellner
2023-02-09 15:47:42 +01:00
parent 42321405b4
commit 0c4156dce9
3 changed files with 33 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
This app is pre-setup with an admin account. The initial credentials are:
**Username**: admin<br/>
**Username**: admin@cloudron.local<br/>
**Password**: admin<br/>
Please change the admin email and password credentials immediately.

View File

@@ -7,16 +7,38 @@ mkdir -p /run/traccar/logs /app/data/media
echo -e "[client]\npassword=${CLOUDRON_MYSQL_PASSWORD}" > /run/traccar/mysql-extra
readonly mysql="mysql --defaults-file=/run/traccar/mysql-extra --user=${CLOUDRON_MYSQL_USERNAME} --host=${CLOUDRON_MYSQL_HOST} -P ${CLOUDRON_MYSQL_PORT} ${CLOUDRON_MYSQL_DATABASE}"
wait_for_table() {
ret=`$mysql --skip-column-names -s -e "SHOW TABLES LIKE '$1';"`
while [ "$ret" != "$1" ]; do
echo "=> Table $1 not yet created, waiting ..."
sleep 1;
ret=($mysql --skip-column-names -s -e "SHOW TABLES LIKE '$1';")
echo "ret was ${ret}"
done
}
disable_registration() {
sleep 10
echo "==> disabling registration"
wait_for_table tc_servers;
echo "==> Disabling registration"
$mysql -e "UPDATE tc_servers SET registration=0 WHERE id=1"
}
ensure_admin_account() {
wait_for_table tc_users;
echo "==> Ensure admin account"
count=`$mysql --skip-column-names -s -e "SELECT COUNT(*) FROM tc_users WHERE name='admin';"`
if [[ "$count" = "0" ]]; then
echo "==> Create initial admin account"
# Values are from https://github.com/traccar/traccar/blob/master/schema/changelog-3.3.xml#L179 which is not used anymore, but we still want the admin account
$mysql -e "INSERT INTO tc_users (name, email, hashedpassword, salt, administrator) VALUES ('admin', 'admin@cloudron.local', 'D33DCA55ABD4CC5BC76F2BC0B4E603FE2C6F61F4C1EF2D47', '000000000000000000000000000000000000000000000000', TRUE)"
fi
}
echo "=> Ensure traccar.xml config"
if [[ ! -f /app/data/traccar.xml ]]; then
cp /app/pkg/traccar.xml.template /app/data/traccar.xml
disable_registration &
fi
echo "=> Ensure database settings"
@@ -58,6 +80,9 @@ xmlstarlet ed --inplace \
--update '//properties/entry[@key="mail.smtp.password"]' -v "${CLOUDRON_MAIL_SMTP_PASSWORD}" \
/app/data/traccar.xml
disable_registration &
ensure_admin_account &
chown -R cloudron /run/traccar /app/data
# https://www.traccar.org/optimization/

View File

@@ -27,10 +27,12 @@ describe('Application life cycle test', function () {
const LOCATION = 'test';
const TEST_TIMEOUT = 10000;
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
const ADMIN_USERNAME = 'admin'; // the login form is called email but accepts usernames
const ADMIN_PASSWORD = 'admin';
const DEVICE_NAME = 'FancyDevice';
const DEVICE_IDENTIFIER = 'device1';
const ADMIN_USERNAME = 'admin@cloudron.local';
const ADMIN_PASSWORD = 'admin';
const EMAIL = process.env.EMAIL;
const PASSWORD = process.env.PASSWORD;
var browser, app;