One-click Add and start Redis other ports are as follows
#!/bin/bash
Set--' getopt d:p:h $* '
Getopt_rc=$?
If ["$getopt _rc"-ne "0"]; Then
Pgm= ' basename $ '
echo "$PGM $getopt _rc Process failed during getopt attempt-illegal parameters"
Exit 10
Fi
While [$#-GT 0]; Todo
Case is in
-P)
Shift
New_port=$1
Shift
;;
--)
Shift
Break
Esac
Done
If [-Z "$NEW _port"]; Then
echo "-p [port] must input"
Exit
Fi
Config_dir= '/etc '
config= "$CONFIG _dir"/redis. " $NEW _port ". conf
replace_port= "50{s/6379/$NEW _port/}" # Replaces line 50th only
Replace_db= "182{s/dump.rdb/dump. $NEW _port.rdb/}" # Replaces line 182th only
CP $CONFIG _dir/redis.conf $CONFIG && sed-i-e $REPLACE _port $CONFIG && sed-i-e $REPLACE _db $CONFIG
/usr/local/bin/redis-server $CONFIG
Note:
Use the SED command to replace only one row.
Save As Add_redis_port.sh, using the method:
chmod +x./add_redis_port.sh
./add_redis_port.sh-p 6588