Skip to content
Snippets Groups Projects
Commit 7e4d7546 authored by Bob Mottram's avatar Bob Mottram
Browse files

Avoid the possibility of app settings file being changed while it is being parsed

parent a8a9857f
No related branches found
No related tags found
No related merge requests found
......@@ -1616,28 +1616,32 @@ function update_app_settings {
if [ ! -f "$appsettings_file" ]; then
return
fi
settings_data=$(cat "$appsettings_file")
rm "$appsettings_file"
cp "$appsettings_file" "$webadmin_install_dir/appsettings.txt"
echo '' >> "$webadmin_install_dir/appsettings.txt"
echo 'update_app_settings' >> "$webadmin_install_dir/appsettings.txt"
if grep -q ',' "$appsettings_file"; then
app_name=$(awk -F ',' '{print $1}' < "$appsettings_file")
if [[ "$settings_data" == *','* ]]; then
app_name=$(echo "$settings_data" | awk -F ',' '{print $1}')
echo "app_name: ${app_name}" >> "$webadmin_install_dir/appsettings.txt"
if [ "$app_name" ]; then
app_filename="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"
echo "app_filename: ${app_filename}" >> "$webadmin_install_dir/appsettings.txt"
if [ -f "$app_filename" ]; then
app_function=$(awk -F ',' '{print $2}' < "$appsettings_file")
app_function=$(echo "$settings_data" | awk -F ',' '{print $2}')
echo "app_function: ${app_function}" >> "$webadmin_install_dir/appsettings.txt"
if [ "$app_function" ]; then
if grep -q "function setting_${app_function} {" "$app_filename"; then
app_value=$(awk -F ',' '{print $3}' < "$appsettings_file")
echo "app_value: ${app_value}" >> "$webadmin_install_dir/appsettings.txt"
app_value=$(echo "$settings_data" | awk -F ',' '{print $3}')
echo "test123" >> "$webadmin_install_dir/appsettings.txt"
echo "app_value: ${app_value}" >> "$webadmin_install_dir/appsettings.txt"
echo "script: $appsettings_script" >> "$webadmin_install_dir/appsettings.txt"
check_for_existing_processes $appsettings_script
ls -l $appsettings_script >> "$webadmin_install_dir/appsettings.txt"
{ echo "echo \"Beginning webadmin ${app_name} app settings change \$(date)\"";
echo "PROJECT_NAME=$PROJECT_NAME";
echo "source $app_filename";
......@@ -1658,7 +1662,6 @@ function update_app_settings {
echo 'No settings specified' >> "$webadmin_install_dir/appsettings.txt"
chown www-data:www-data "$webadmin_install_dir/appsettings.txt"
fi
rm "$appsettings_file"
}
# If the freedombone command is already running then kill its process
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment