Update open5gs-dbctl (#1562)
I added four additional commands which are useful in case not using the GUI (add UE using a specific APN, add UE using a specific slice and APN, modify a slice adding an APN, modify an UE adding a new slice + APN)
This commit is contained in:
parent
de0ba3f9dc
commit
78b1dc77ff
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=0.9.1
|
||||
version=0.10.1
|
||||
|
||||
display_help() {
|
||||
echo "open5gs-dbctl: Open5GS Database Configuration Tool ($version)"
|
||||
|
@ -17,6 +17,11 @@ display_help() {
|
|||
echo " type {imsi type}: changes the PDN-Type of the first PDN: 0 = IPv4, 1 = IPv6, 2 = IPv4v6, 3 = v4 OR v6"
|
||||
echo " help: displays this message and exits"
|
||||
echo " default values are as follows: APN \"internet\", dl_bw/ul_bw 1 Gbps, PGW address is 127.0.0.3, IPv4 only"
|
||||
echo " add_ue_with_apn {imsi key opc apn}: adds a user to the database with a specific apn,"
|
||||
echo " add_ue_with_slice {imsi key opc apn sst sd}: adds a user to the database with a specific apn, sst and sd"
|
||||
echo " update_apn {imsi apn slice_num}: adds an APN to the slice number slice_num of an existent UE"
|
||||
echo " update_slice {imsi apn sst sd}: adds an slice to an existent UE"
|
||||
|
||||
}
|
||||
|
||||
while test $# -gt 0; do
|
||||
|
@ -448,4 +453,225 @@ if [ "$1" = "type" ]; then
|
|||
exit $?
|
||||
fi
|
||||
|
||||
if [ "$1" = "add_ue_with_apn" ]; then
|
||||
if [ "$#" -eq 5 ]; then
|
||||
IMSI=$2
|
||||
KI=$3
|
||||
OPC=$4
|
||||
APN=$5
|
||||
|
||||
mongo --eval "db.subscribers.update( { \"imsi\" : \"$IMSI\" },
|
||||
{ \$setOnInsert:
|
||||
{
|
||||
\"imsi\" : \"$IMSI\",
|
||||
\"subscribed_rau_tau_timer\" : NumberInt(12),
|
||||
\"network_access_mode\" : NumberInt(0),
|
||||
\"subscriber_status\" : NumberInt(0),
|
||||
\"access_restriction_data\" : NumberInt(32),
|
||||
\"slice\" :
|
||||
[{
|
||||
\"sst\" : NumberInt(1),
|
||||
\"default_indicator\" : true,
|
||||
\"_id\" : new ObjectId(),
|
||||
\"session\" :
|
||||
[{
|
||||
\"name\" : \"$APN\",
|
||||
\"type\" : NumberInt(3),
|
||||
\"_id\" : new ObjectId(),
|
||||
\"pcc_rule\" : [],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"qos\" :
|
||||
{
|
||||
\"index\" : NumberInt(9),
|
||||
\"arp\" :
|
||||
{
|
||||
\"priority_level\" : NumberInt(8),
|
||||
\"pre_emption_capability\" : NumberInt(1),
|
||||
\"pre_emption_vulnerability\" : NumberInt(1),
|
||||
},
|
||||
},
|
||||
}],
|
||||
}],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3),},
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"security\" :
|
||||
{
|
||||
\"k\" : \"$KI\",
|
||||
\"amf\" : \"8000\",
|
||||
\"op\" : null,
|
||||
\"opc\" : \"$OPC\"
|
||||
},
|
||||
\"__v\" : 0
|
||||
},
|
||||
},
|
||||
upsert=true);" $DB_URI
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_apn imsi key opc apn\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "add_ue_with_slice" ]; then
|
||||
if [ "$#" -eq 7 ]; then
|
||||
IMSI=$2
|
||||
KI=$3
|
||||
OPC=$4
|
||||
APN=$5
|
||||
SST=$6
|
||||
SD=$7
|
||||
|
||||
mongo --eval "db.subscribers.update( { \"imsi\" : \"$IMSI\" },
|
||||
{ \$setOnInsert:
|
||||
{
|
||||
\"imsi\" : \"$IMSI\",
|
||||
\"subscribed_rau_tau_timer\" : NumberInt(12),
|
||||
\"network_access_mode\" : NumberInt(0),
|
||||
\"subscriber_status\" : NumberInt(0),
|
||||
\"access_restriction_data\" : NumberInt(32),
|
||||
\"slice\" :
|
||||
[{
|
||||
\"sst\" : NumberInt($SST),
|
||||
\"sd\" : \"$SD\",
|
||||
\"default_indicator\" : true,
|
||||
\"_id\" : new ObjectId(),
|
||||
\"session\" :
|
||||
[{
|
||||
\"name\" : \"$APN\",
|
||||
\"type\" : NumberInt(3),
|
||||
\"_id\" : new ObjectId(),
|
||||
\"pcc_rule\" : [],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"qos\" :
|
||||
{
|
||||
\"index\" : NumberInt(9),
|
||||
\"arp\" :
|
||||
{
|
||||
\"priority_level\" : NumberInt(8),
|
||||
\"pre_emption_capability\" : NumberInt(1),
|
||||
\"pre_emption_vulnerability\" : NumberInt(1),
|
||||
},
|
||||
},
|
||||
}],
|
||||
}],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3),},
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"security\" :
|
||||
{
|
||||
\"k\" : \"$KI\",
|
||||
\"amf\" : \"8000\",
|
||||
\"op\" : null,
|
||||
\"opc\" : \"$OPC\"
|
||||
},
|
||||
\"__v\" : 0
|
||||
},
|
||||
},
|
||||
upsert=true);" $DB_URI
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl add_ue_with_slice imsi key opc apn sst sd\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "update_apn" ]; then
|
||||
if [ "$#" -eq 4 ]; then
|
||||
IMSI=$2
|
||||
APN=$3
|
||||
SLICE_NUM=$4
|
||||
|
||||
mongo --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
|
||||
{\$push: { \"slice.$SLICE_NUM.session\":
|
||||
{
|
||||
\"name\" : \"$APN\",
|
||||
\"type\" : NumberInt(3),
|
||||
\"_id\" : new ObjectId(),
|
||||
\"pcc_rule\" : [],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"qos\" :
|
||||
{
|
||||
\"index\" : NumberInt(9),
|
||||
\"arp\" :
|
||||
{
|
||||
\"priority_level\" : NumberInt(8),
|
||||
\"pre_emption_capability\" : NumberInt(1),
|
||||
\"pre_emption_vulnerability\" : NumberInt(1),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
});" $DB_URI
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_apn imsi apn num_slice\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "update_slice" ]; then
|
||||
if [ "$#" -eq 5 ]; then
|
||||
IMSI=$2
|
||||
APN=$3
|
||||
SST=$4
|
||||
SD=$5
|
||||
|
||||
mongo --eval "db.subscribers.updateOne({ \"imsi\": \"$IMSI\"},
|
||||
{\$push: { \"slice\":
|
||||
|
||||
{
|
||||
\"sst\" : NumberInt($SST),
|
||||
\"sd\" : \"$SD\",
|
||||
\"default_indicator\" : false,
|
||||
\"_id\" : new ObjectId(),
|
||||
\"session\" :
|
||||
[{
|
||||
\"name\" : \"$APN\",
|
||||
\"type\" : NumberInt(3),
|
||||
\"_id\" : new ObjectId(),
|
||||
\"pcc_rule\" : [],
|
||||
\"ambr\" :
|
||||
{
|
||||
\"uplink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
\"downlink\" : { \"value\": NumberInt(1), \"unit\" : NumberInt(3) },
|
||||
},
|
||||
\"qos\" :
|
||||
{
|
||||
\"index\" : NumberInt(9),
|
||||
\"arp\" :
|
||||
{
|
||||
\"priority_level\" : NumberInt(8),
|
||||
\"pre_emption_capability\" : NumberInt(1),
|
||||
\"pre_emption_vulnerability\" : NumberInt(1),
|
||||
},
|
||||
},
|
||||
}]
|
||||
}
|
||||
|
||||
}
|
||||
});" $DB_URI
|
||||
exit $?
|
||||
fi
|
||||
|
||||
echo "open5gs-dbctl: incorrect number of args, format is \"open5gs-dbctl update_slice imsi apn sst sd\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
display_help
|
||||
|
|
Loading…
Reference in New Issue