feat: parallel actions

This commit is contained in:
GenZmeY 2020-08-07 14:20:40 +03:00
parent debe08037e
commit 2198482459
6 changed files with 36 additions and 5 deletions

View File

@ -106,6 +106,7 @@ function ban_ID3 () # $1: ID3
ID3="$1"
for Instance in $(show_instances)
do
(
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
local BanStr="(Uid=(A=$ID3,B=$StrangeConstUID))"
local Service=$(service_name "$Instance")
@ -121,7 +122,9 @@ function ban_ID3 () # $1: ID3
multini -a "$Config" "Engine.AccessControl" "BannedIDs" "$BanStr"
fi
fi
done
) &
done
wait
}
function unban_ID3 () # $1: ID3
@ -132,6 +135,7 @@ function unban_ID3 () # $1: ID3
ID3="$1"
for Instance in $(show_instances)
do
(
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
local BanStr="(Uid=(A=$ID3,B=$StrangeConstUID))"
local Service=$(service_name "$Instance")
@ -156,6 +160,8 @@ function unban_ID3 () # $1: ID3
multini -d "$Config" "Engine.AccessControl" "BannedIDs" "$BanStr"
fi
fi
done
) &
done
wait
}

View File

@ -145,6 +145,7 @@ function instance_chat ()
for Instance in $InstanceList
do
(
if instance_exists "$Instance"; then
local Service=$(service_name "$Instance")
if systemctl -q is-active $Service ; then
@ -159,7 +160,9 @@ function instance_chat ()
else
echo "Instance $Instance not exitst"
fi
) &
done
wait
}
function instance_delete () # $*: [InstanceName[s]]
@ -171,13 +174,16 @@ function instance_delete () # $*: [InstanceName[s]]
if [[ "$Answ" == "y" || "$Answ" == "Y" ]]; then
for Instance in $(show_instances)
do
(
instance_stop "$Instance"
instance_delete "$Instance"
) &
done
fi
else
for Instance in $*
do
do
(
if instance_exists "$Instance"; then
local InstanceDir="$InstanceConfigDir/$Instance"
instance_stop "$Instance"
@ -186,8 +192,10 @@ function instance_delete () # $*: [InstanceName[s]]
else
echo "Instance $Instance not exists"
fi
) &
done
fi
wait
}
function instance_disable () # $*: [InstanceName[s]]

View File

@ -32,6 +32,7 @@ function maprotate_load () # $*: Instance[s]
for Instance in $InstanceList
do
(
local Service=$(service_name "$Instance")
local MapRotate="$InstanceConfigDir/$Instance/MapRotate.ini"
if ! instance_exists "$Instance"; then
@ -69,7 +70,9 @@ function maprotate_load () # $*: Instance[s]
sed -i --follow-symlinks -r "/(ActiveMapCycle=|GameMapCycles=)/d" "$Config"
sed -i --follow-symlinks "/\[KFGame\.KFGameInfo\]/ r $MapRotate" "$Config"
fi
) &
done
wait
}
function maprotate_save () # $*: Instance[s]

View File

@ -37,6 +37,7 @@ function password_game () # $1: Password (if empty, use: ''), $*: Instance[s]
for Instance in $InstanceList
do
(
if instance_exists "$Instance"; then
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
local Service=$(service_name "$Instance")
@ -52,7 +53,9 @@ function password_game () # $1: Password (if empty, use: ''), $*: Instance[s]
else
echo "Instance $Instance not exitst"
fi
) &
done
wait
}
function password_admin () # $1: Password (if empty, use: ''), $*: Instance[s]
@ -73,6 +76,7 @@ function password_admin () # $1: Password (if empty, use: ''), $*: Instance[s]
for Instance in $InstanceList
do
(
if instance_exists "$Instance"; then
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
local Service=$(service_name "$Instance")
@ -88,6 +92,8 @@ function password_admin () # $1: Password (if empty, use: ''), $*: Instance[s]
else
echo "Instance $Instance not exitst"
fi
) &
done
wait
}

View File

@ -90,6 +90,7 @@ function workshop_add () # $*: WorkshopID[s]
for Instance in $(show_instances)
do
(
local Config="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
multini -ar "$Config" "IpDrv.TcpNetDriver" "DownloadManagers" "OnlineSubsystemSteamworks.SteamWorkshopDownload"
for Map in $*
@ -100,7 +101,9 @@ function workshop_add () # $*: WorkshopID[s]
multini -ar "$Config" "OnlineSubsystemSteamworks.KFWorkshopSteamworks" "ServerSubscribedWorkshopItems" "$WorkshopID"
fi
done
) &
done
wait
}
function workshop_delete () # $*: WorkshopID[s]
@ -117,6 +120,7 @@ function workshop_delete () # $*: WorkshopID[s]
rm -rf "$Cache" "$Downl"
for Instance in $(show_instances)
do
(
local ConfigEngine="$InstanceConfigDir/$Instance/LinuxServer-KFEngine.ini"
multini -d "$ConfigEngine" "OnlineSubsystemSteamworks.KFWorkshopSteamworks" "ServerSubscribedWorkshopItems" "$WorkshopID"
if echo "$WsName" | grep -qP '\.kfm$' ; then
@ -125,7 +129,9 @@ function workshop_delete () # $*: WorkshopID[s]
local ConfigGame="$InstanceConfigDir/$Instance/LinuxServer-KFGame.ini"
multini -d "$ConfigGame" "$WsNameShort KFMapSummary"
fi
done
) &
done
wait
done
}
@ -138,6 +144,7 @@ function workshop_sync ()
# TODO: Make it faster
for Instance in $(show_instances)
do
(
local Service=$(service_name "$Instance")
if ! instance_exists "$Instance"; then
echo "Instance $Instance not exitst"
@ -168,6 +175,8 @@ function workshop_sync ()
fi
done
fi
) &
done
wait
}

1
TODO
View File

@ -7,6 +7,5 @@
- ban history
- temporary ban
- generate unique password for server bot on install
- parallel actions
- bash completion