Page MenuHomeMiraheze
Paste P478

mass use assignImportedEdits.php with bash script and two lists of users
ActivePublic

Authored by Reception123 on Jan 19 2023, 13:02.
#!/bin/bash
# Set the path to the assignImportedEdits.php script
script_path="/srv/mediawiki/w/extensions/MirahezeMagic/maintenance/assignImportedEdits.php"
# Set the path to the "from" usernames list
from_list="/home/reception/from_usernames.txt"
# Set the path to the "to" usernames list
to_list="/home/reception/to_usernames.txt"
# Read the "from" usernames into an array
IFS=$'\n' read -d '' -r -a from_usernames < $from_list
# Read the "to" usernames into an array
IFS=$'\n' read -d '' -r -a to_usernames < $to_list
# Loop through the "from" usernames array
for ((i=0; i<${#from_usernames[@]}; i++)); do
from_username=${from_usernames[i]}
# Check if the "from" username contains an "&" character
if [[ $from_username == *"&"* ]]; then
# Split the "from" username on the "&" character
IFS='&' read -ra usernames <<< "$from_username"
# Loop through the split "from" usernames
for username in "${usernames[@]}"; do
to_username=${to_usernames[i]}
sudo -u www-data php $script_path --from $username --to $to_username --wiki hangoverswiki --no-run
done
else
to_username=${to_usernames[i]}
sudo -u www-data php $script_path --from $from_username --to $to_username --wiki hangoverswiki --no-run
fi
done