summaryrefslogtreecommitdiffstats
path: root/satellit_installer/includes/10-password_helper.inc
blob: 30eece9485f50abd8e004df8968d02bab8d279df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

generate_password() {
	local password="$(< /dev/urandom tr -dc A-Za-z0-9_ | head -c${1:-16};)"
	echo "$password"
}

# This routine has to be used only in conjunction with the prepare_firstrun-script, which
# will enforce the setting of good passwords on first root login after server start.
set_passwords() {
	echo -n "# Setting passwords..."
	OPENSLX_PASS="$(generate_password)"
	MYSQL_ROOT_PASS="$(generate_password)"
	MYSQL_OPENSLX_PASS="$(generate_password)"
	MYSQL_SAT_PASS="$(generate_password)"
	
	# Keep in mind the passwords stored here will be valid only temporary,
	# as they will be changed by the dropper script.
	# If you need the permanently valid password, you will need to 
	# decrypt static_files/new_passwords.encrypted.
	echo "OPENSLX_PASS=$OPENSLX_PASS"			>  "$CONFIGDIR"/config
	echo "MYSQL_ROOT_PASS=$MYSQL_ROOT_PASS"			>> "$CONFIGDIR"/config
	echo "MYSQL_OPENSLX_PASS=$MYSQL_OPENSLX_PASS"		>> "$CONFIGDIR"/config
	echo "MYSQL_SAT_PASS=$MYSQL_SAT_PASS"			>> "$CONFIGDIR"/config
	echo "ok."
}