Browse Source

better standardise random

pull/4326/head
Daniel Gibbs 2 years ago
parent
commit
6054dc1464
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 4
      lgsm/modules/fix_samp.sh
  2. 9
      lgsm/modules/info_messages.sh
  3. 8
      lgsm/modules/install_config.sh
  4. 4
      lgsm/modules/update_mcb.sh

4
lgsm/modules/fix_samp.sh

@ -16,8 +16,8 @@ if [ -f "${servercfgfullpath}" ]; then
fixname="change default rcon password"
fn_fix_msg_start
fn_script_log_info "changing rcon/admin password."
random=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs)
rconpass="admin${random}"
randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
rconpass="admin${randomstring}"
sed -i "s/rcon_password changeme/rcon_password ${rconpass}/g" "${servercfgfullpath}"
fn_fix_msg_end
fi

9
lgsm/modules/info_messages.sh

@ -7,15 +7,6 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# Separator is different for details.
fn_messages_separator() {
if [ "${commandname}" == "DETAILS" ]; then
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
else
echo -e "${bold}=================================${default}"
fi
}
# Removes the passwords form all but details.
fn_info_message_password_strip() {
if [ "${commandname}" != "DETAILS" ]; then

8
lgsm/modules/install_config.sh

@ -78,9 +78,9 @@ fn_default_config_local() {
# PASSWORD to random password
fn_set_config_vars() {
if [ -f "${servercfgfullpath}" ]; then
random=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2>/dev/null | head -c 8 | xargs)
randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
servername="LinuxGSM"
rconpass="admin${random}"
rconpass="admin${randomstring}"
echo -e "changing hostname."
fn_script_log_info "changing hostname."
fn_sleep_time
@ -121,8 +121,8 @@ fn_set_dst_config_vars() {
fn_sleep_time
echo -e "randomizing cluster key."
fn_script_log_info "randomizing cluster key."
randomkey=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs)
sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
sed -i "s/CLUSTERKEY/${randomstring}/g" "${clustercfgfullpath}"
fn_sleep_time
else
echo -e "${clustercfg} is already configured."

4
lgsm/modules/update_mcb.sh

@ -50,10 +50,10 @@ fn_update_localbuild() {
fn_update_remotebuild() {
# Random number for userAgent
randnum=$((1 + RANDOM % 5000))
randomint=$(tr -dc 0-9 < /dev/urandom 2> /dev/null | head -c 4 | xargs)
# Get remote build info.
if [ "${mcversion}" == "latest" ]; then
remotebuildversion=$(curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -Ls -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randnum}.212 Safari/537.36" "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*' | sed 's/.*\///' | grep -Eo "[.0-9]+[0-9]")
remotebuildversion=$(curl -H "Accept-Encoding: identity" -H "Accept-Language: en" -Ls -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.${randomint}.212 Safari/537.36" "https://www.minecraft.net/en-us/download/server/bedrock/" | grep -o 'https://minecraft.azureedge.net/bin-linux/[^"]*' | sed 's/.*\///' | grep -Eo "[.0-9]+[0-9]")
else
remotebuildversion="${mcversion}"
fi

Loading…
Cancel
Save