Skip to content

Commit

Permalink
better standardise random
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Oct 3, 2023
1 parent 42d14f5 commit 6054dc1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lgsm/modules/fix_samp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions lgsm/modules/info_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/update_mcb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6054dc1

Please sign in to comment.