Answer the question
In order to leave comments, you need to log in
How to automatically change the password in the config?
Hello. There is a game server and I need to somehow automatically change one parameter in the config. For example, there is a variable rcon "faufI21FA"
faufI21FA - a password that needs to be changed randomly. Tell me the bash code so that I can specify the path to the txt file in which I need to write a random password in "". For example, I have this rcon.sh script in root, and the txt file is in /home/server/config.txt. So that I enter sh rcon.sh and the password faufI21FA is replaced with any other. I hope you understand me))
----------
You need a random pass and so that the new pass can also be replaced. I want to do it through cron so that every 30 minutes a variable in the
rcon "faufI21FA" config changes for example to rcon "VFyffa21" and this one to rcon "FGVsa24" and so on
Answer the question
In order to leave comments, you need to log in
#!/bin/bash
newpass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
sed -i.bak "s/^rcon .*$/rcon $newpass/" /path/to/myconfig.cfg
pass=$(/urandom tr -dc '[email protected]#^&)(*%KMNP-Za-hjk5-9mnp-z1-9' | head -c8)
sed -i 's/rcon. */rcon '${pass}'/g' /home/server/config.txt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question