#!/bin/sh

SIMLOCK="/tmp/lock/sim.lock"

sim=$(uci get network.MOBILE.sim)
[ -n "$sim" ] && [ "$sim" = "1" ] && {
	uci set network.MOBILE.sim=1
	uci commit network
	
	if ! lock -n $SIMLOCK; then
        logger -t sim "change sim processing"
        return
	fi
	
	logger -t sim "change sim1"
	. /lib/netifd/proto/sim.sh
	setup_simcard 0
	
	logger -t sim "unlock $SIMLOCK"
	lock -u $SIMLOCK
}