diff --git a/src/freedombone-app-irc b/src/freedombone-app-irc index 06669c73..d9967d8b 100755 --- a/src/freedombone-app-irc +++ b/src/freedombone-app-irc @@ -227,14 +227,7 @@ function irc_set_global_password_base { function change_password_irc { new_global_password="$2" - # Change the password for all users - for d in /home/*/ ; do - USERNAME=$(echo "$d" | awk -F '/' '{print $3}') - if [[ $(is_valid_user "$USERNAME") == "1" ]]; then - ${PROJECT_NAME}-pass -u "$USERNAME" -a irc -p "$new_global_password" - fi - done - + set_password_for_all_users irc "$new_global_password" irc_set_global_password_base "$new_global_password" } @@ -522,13 +515,8 @@ function install_irc_server { IRC_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})" - # Change the password for all users - for d in /home/*/ ; do - USERNAME=$(echo "$d" | awk -F '/' '{print $3}') - if [[ $(is_valid_user "$USERNAME") == "1" ]]; then - ${PROJECT_NAME}-pass -u "$USERNAME" -a irc -p "$IRC_PASSWORD" - fi - done + set_password_for_all_users irc "$IRC_PASSWORD" + echo '**************************************************' > /etc/ngircd/motd echo $'* F R E E D O M B O N E I R C *' >> /etc/ngircd/motd diff --git a/src/freedombone-app-mumble b/src/freedombone-app-mumble index 526544cd..e71b1e8e 100755 --- a/src/freedombone-app-mumble +++ b/src/freedombone-app-mumble @@ -55,14 +55,7 @@ function install_interactive_mumble { function change_password_mumble { new_mumble_password="$2" - # Change the password for all users - for d in /home/*/ ; do - USERNAME=$(echo "$d" | awk -F '/' '{print $3}') - if [[ $(is_valid_user "$USERNAME") == "1" ]]; then - ${PROJECT_NAME}-pass -u "$USERNAME" -a mumble -p "$new_mumble_password" - fi - done - + set_password_for_all_users mumble "$new_mumble_password" sed -i "s|serverpassword=.*|serverpassword=$new_mumble_password|g" /etc/mumble-server.ini systemctl restart mumble-server } @@ -268,13 +261,7 @@ function install_mumble { update_default_domain systemctl restart mumble-server - # Change the password for all users - for d in /home/*/ ; do - USERNAME=$(echo "$d" | awk -F '/' '{print $3}') - if [[ $(is_valid_user "$USERNAME") == "1" ]]; then - ${PROJECT_NAME}-pass -u "$USERNAME" -a mumble -p "$MUMBLE_SERVER_PASSWORD" - fi - done + set_password_for_all_users mumble "$MUMBLE_SERVER_PASSWORD" function_check configure_firewall_for_mumble configure_firewall_for_mumble diff --git a/src/freedombone-utils-keys b/src/freedombone-utils-keys index 04daabb5..cc112853 100755 --- a/src/freedombone-utils-keys +++ b/src/freedombone-utils-keys @@ -242,4 +242,16 @@ function interactive_key_recovery { fi } +function set_password_for_all_users { + app_name="$1" + change_password="$2" + + for d in /home/*/ ; do + USERNAME=$(echo "$d" | awk -F '/' '{print $3}') + if [[ $(is_valid_user "$USERNAME") == "1" ]]; then + ${PROJECT_NAME}-pass -u "${USERNAME}" -a "${app_name}" -p "${change_password}" + fi + done +} + # NOTE: deliberately there is no "exit 0"