How to access init.js file




I have created one workspace and I want to put one alert statement in init.js file, how can it possible through shell scritping(I mean through automation)



Init.js is not stored in a file, it is in a database, and only way to modify it is to have password and username of a user for whom you want to modify it


I have username and password then how can I put my statements in init.js using services (I mean using curl command)


you can do it by using the code from, and inspecting network requests in browser devtools.

# get token using password
token=$(curl -d '{"username": "'$USERNAME'", "password": "'$PASSWORD'", "client_id": "cli"}' -H "content-type: application/json"); echo $token      

# get settings
settings="$(curl$token -X GET)"

# script tht we want to add

# add the script to settings
settings="$(node -p "
    s=JSON.parse(process.argv[1] || '{}');
    if (s.config == null) s.config = {};
    if (s.config['init.js'] == null) s.config['init.js']= {};
    s.config['init.js']['json()'] = '$script';
    JSON.stringify(s)" "$settings")"

# save settings
curl$token -X PUT  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json' --data "settings=$settings"

# get settings again and verify that everything went well
curl$token -X GET

How can I confirm : workspace shared properly using curl command