blob: 5076e5a9018b9d4fab8fb73f54296fc48a15b532 [file] [log] [blame]
#!/bin/sh
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
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