Changeset 14 for scripts/usr/local/bin/7dtd-common.sh
- Timestamp:
- May 17, 2014, 6:01:31 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
scripts/usr/local/bin/7dtd-common.sh
r13 r14 1 1 #!/bin/bash 2 # Version 22 # Version 3 3 3 4 4 # Provides common functions for 7dtd-scripts. Not intended to be run directly. … … 23 23 24 24 # Check if the given instance name is an existing instance 25 # On failure exit the script!26 25 # Params: 27 26 # 1: Instance name 28 checkInstance() { 27 # Returns: 28 # 0/1 instance not valid/valid 29 isValidInstance() { 29 30 if [ -z $1 ]; then 30 echo "No instance given!" 31 exit 2 31 echo 0 32 else 33 if [ ! -d $(getInstancePath $1) ]; then 34 echo 0 35 else 36 if [ ! -f $(getInstancePath $1)/config.xml ]; then 37 echo 0 38 else 39 echo 1 40 fi 41 fi 32 42 fi 33 if [ ! -d $(getInstancePath $1) ]; then 34 echo "Instance $1 does not exist!" 35 exit 3 43 } 44 45 # Check if the given instance is valid, exit the script otherwise 46 # Params: 47 # 1: instance name 48 checkInstanceValid() { 49 if [ -z $1 ]; then 50 echo "Missing parameter <instance>" 51 exit 1 52 fi 53 if [ $(isValidInstance $1) -eq 0 ]; then 54 echo "'$1' is not a valid instance" 55 exit 1 36 56 fi 37 57 } … … 50 70 echo 0 51 71 fi 72 } 73 74 # Get list of defined instances 75 # Returns: 76 # List of instances 77 getInstanceList() { 78 for IF in $SDTD_BASE/instances/*; do 79 I=`basename $IF` 80 if [ $(isValidInstance $I) -eq 1 ]; then 81 echo $I 82 fi 83 done 52 84 } 53 85 … … 74 106 # Property value 75 107 getConfigValue() { 76 CONF=$(getInstancePath $1)/ serverconfig.xml77 xml lint --xpath "string(/ServerSettings/property[@name='$2']/@value)" $CONF108 CONF=$(getInstancePath $1)/config.xml 109 xmlstarlet sel -t -v "/ServerSettings/property[@name='$2']/@value" $CONF 78 110 } 79 111
Note:
See TracChangeset
for help on using the changeset viewer.