#!/bin/sh

config_file="/etc/checkbox.d/$1.ini"

sed -i 's|checkbox_directory|checkbox_share|' $config_file

if [ "$1" = "checkbox" ]; then
    temp_file=`tempfile -m 0644 -p $1`

    awk '{print}; /^directories.*plugins$/ { print "persist_filename = %(checkbox_data)s/plugins.bpickle" }' < $config_file > $temp_file
    mv -f $temp_file $config_file

    sed -i 's/cache_file.*submission.xml/filename = %(checkbox_data)s\/submission.xml/' $config_file
    cat <<'EOF' >>$config_file
[checkbox/registries/gconf]
directory = /home
source = %(directory)s/$user/.gconf
command = gconftool-2 -R / --config-source xml:readwrite:%(source)s

[checkbox/registries/hw]
command = lshw -numeric 2>/dev/null
version = lshw -version 2>/dev/null

[checkbox/plugins/disk_info]
filename = /var/log/installer/casper.log

[checkbox/plugins/lock_prompt]
filename = %(checkbox_data)s/lock

[checkbox/plugins/packages_info]
max_per_request = 100

[checkbox/plugins/results_info]
max_per_request = 20

[checkbox/plugins/test_prompt]
plugin_priorities = manual

EOF
fi
