blob: d6af526186e0e1353225c8375d1a75346b210043 [file] [log] [blame]
#!/bin/sh
set -e
VM_ARGS=$SNAP_DATA/etc/vm.args
## add or replace for the vm.arg file
_modify_vm_args() {
opt=$1
value="$2"
replace_line="-$opt $value"
if $(grep -q "^-$opt " $VM_ARGS); then
sed "s/^-$opt .*/$replace_line/" $VM_ARGS 2>/dev/null >${VM_ARGS}.new
mv -f ${VM_ARGS}.new $VM_ARGS 2>/dev/null
else
echo $replace_line >> $VM_ARGS
fi
}
# The vm_args file can only be changed from the filesystem
# configutaion vm.args file
VM_ARGS_OPTIONS="name setcookie"
for key in $VM_ARGS_OPTIONS
do
val=$(snapctl get $key)
if [ ! -z "$val" ]; then
_modify_vm_args $key $val
sleep 0.125
fi
done