How to change Advanced Settings from the command line

This hopefully a simple command, but can I do something like:

amp_conf [AMPMGRPASS] => [asdf987asfdsadfiKJ] (random password that is not amp111)

from the command line? Just one more thing I’m trying to automate in starting up a new server. Thanks.

you could use something that replaces all instances of it using sed:

sed -i ‘s~AMPMGRPASS = amp111~AMPMGRPASS = $(stackoverflow ftw!)~g’ /etc/amportal.conf
sed -i ‘s~AMPMGRPASS = amp111~AMPMGRPASS = $(stackoverflow ftw!)~g’ /etc/asterisk/extensions_additional.conf

Those are the only instances I found of it in our configs, not sure if that’s 100% accurate. Deserves some testing first.

EDIT: Stackoverflow helped me create a bash script that returns a random string; edit and apply as wanted:

[code]#!/bin/bash
function randomstr() {

#the character set you want to use    
    charset=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

    #the length of above string
    charlen=${#charset}

    #define output string
    outstr=""

    #do loop X times -- format: {1..x}
    for i in {1..10}; do
            x=$(( $RANDOM % $charlen))
            outstr="$outstr${charset:$x:1}"
    done

    #echo result for use
    echo $outstr

}

echo $(randomstr)[/code]

Finally got back to messing with this. I don’t think changing the values in the files will work. A couple years back there was a blog post from Phillipe about how everything is getting moved into the MySQL database so changing files does not help. I printed out the entire freepbx_settings table and found all the Advanced Settings variables but I guess I don’t know what I’m doing with SQL.

I tried

UPDATE freepbx_settings SET value = ‘kjasfd98df4’ WHERE keyword = ‘AMPMGRPASS’;

which gives no errors initially and looking in Advanced Settings shows the new password but then a bunch of the modules become unavailable and clicking Apply Changes (or doing amportal a r in putty) gives me an error. Restarting the system or just restarting asterisk does nothing. The only way to fix it is to reset the password to default.

So there’s something that I’m missing here, like some other command that needs to be run after changing the table value to allow asterisk to connect to the database.

Try doing both SQL & files.

The ‘correct’ way might involve FreePBX’s BMO, but I’m not sure. I’m less of a programmer more of a sysadmin.