Tripp Lite B097048 Owners Manual for B093- B097- and B098-Series Console Serve - Page 237

Deleting Configuration Values from the CLI

Page 237 highlights

15. Advanced Configuration 15.1.5 Deleting Configuration Values from the CLI The delete-node script is provided to help with deleting nodes from the command line. The "delete-node" script takes one argument: the node name you want to delete (e.g., "config.users.user1" or "config.sdt.hosts.host1"). Delete-node is a general script for deleting any node you desire (users, groups, hosts, UPS systems, etc.) from the command line. The script deletes the specified node and shuffles the remainder of the node values. For example, if there are five users configured and we use the script to delete user 3, then user 4 will become user 3, user 5 will become user 4, and so on. This creates a complication, as this script does NOT check for any other dependencies that the node being deleted may have had. You are responsible for making sure any references and dependencies connected to the deleted node are removed or corrected in the config.xml file. The script treats all nodes the same. The syntax to run the script is # ./delete-node {node name} . To remove user 3: # ./delete-node config.users.user3 The delete-node script #!/bin/bash #User must provide the node to be removed. e.g. "config.users.user1" # Usage: delete-node {full node path} if [ $# != 1 ] then echo "Wrong number of arguments" echo "Usage: delnode {full '.' delimited node path}" exit 2 fi # test for spaces TEMP=`echo "$1" | sed 's/.* .*/N/'` if [ "$TEMP" = "N" ] then echo "Wrong input format" echo "Usage: delnode {full '.' delimited node path}" exit 2 fi # testing if node exists TEMP=`config -g config | grep "$1"` if [ -z "$TEMP" ] then echo "Node $1 not found" exit 0 fi # LASTFIELD is the last field in the node path e.g. "user1" # ROOTNODE is the upper level of the node e.g. "config.users" # NUMBER is the integer value extracted from LASTFIELD e.g. "1" # TOTALNODE is the node name for the total e.g. "config.users.total" # TOTAL is the value of the total number of items before deleting e.g. "3" # NEWTOTAL is the modified total i.e. TOTAL-1 # CHECKTOTAL checks if TOTAL is the actual total items in .xml LASTFIELD=${1##*.} ROOTNODE=${1%.*} NUMBER=`echo $LASTFIELD | sed 's/^[a-zA-Z]*//g'` TOTALNODE=`echo ${1%.*} | sed 's/\(.*\)/\1.total/'` TOTAL=`config -g $TOTALNODE | sed 's/.* //'` NEWTOTAL=$[ $TOTAL -1 ] 237

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288

237
15. Advanced Configuration
15.1.5 Deleting Configuration Values from the CLI
The
delete-node
script is provided to help with deleting nodes from the command line. The “
delete-node
” script takes one
argument: the node name you want to delete (e.g., “
config.users.user1
” or “
config.sdt.hosts.host1
”).
Delete-node is a general script for deleting any node you desire (users, groups, hosts, UPS systems, etc.) from the command
line. The script deletes the specified node and shuffles the remainder of the node values.
For example, if there are five users configured and we use the script to delete user 3, then user 4 will become user 3, user 5
will become user 4, and so on.
This creates a complication, as this script does NOT check for any other dependencies that the node being deleted may have
had. You are responsible for making sure any references and dependencies connected to the deleted node are removed or
corrected in the config.xml file.
The script treats all nodes the same. The syntax to run the script is
# ./delete-node {node name}
. To remove user 3:
# ./delete-node config.users.user3
The delete-node script
#!/bin/bash
#User must provide the node to be removed. e.g. “config.users.user1”
# Usage: delete-node {full node path}
if [ $# != 1 ]
then
echo “Wrong number of arguments”
echo “Usage: delnode {full ‘.’ delimited node path}”
exit 2
# test for spaces
TEMP=`echo “$1” | sed ‘s/.* .*/N/’`
if [ “$TEMP” = “N” ]
then
echo “Wrong input format”
echo “Usage: delnode {full ‘.’ delimited node path}”
exit 2
# testing if node exists
TEMP=`config -g config | grep “$1”`
if [ -z “$TEMP” ]
then
echo “Node $1 not found”
exit 0
# LASTFIELD is the last field in the node path e.g. “user1”
# ROOTNODE is the upper level of the node e.g. “config.users”
# NUMBER is the integer value extracted from LASTFIELD e.g. “1”
# TOTALNODE is the node name for the total e.g. “config.users.total”
# TOTAL is the value of the total number of items before deleting e.g. “3”
# NEWTOTAL is the modified total i.e. TOTAL-1
# CHECKTOTAL checks if TOTAL is the actual total items in .xml
LASTFIELD=${1##*.}
ROOTNODE=${1%.*}
NUMBER=`echo $LASTFIELD | sed ‘s/^[a-zA-Z]*//g’`
TOTALNODE=`echo ${1%.*} | sed ‘s/\(.*\)/\1.total/’`
TOTAL=`config -g $TOTALNODE | sed ‘s/.* //’`
NEWTOTAL=$[ $TOTAL -1 ]