| 1 |
#!/bin/sh |
|---|
| 2 |
|
|---|
| 3 |
. env.sh |
|---|
| 4 |
|
|---|
| 5 |
# change to accomodate different urls, e.g. admin/disable-user?op=re_enable, admin/disable-user?op=disable, etc. |
|---|
| 6 |
op_flag="notify_expiring_soon" |
|---|
| 7 |
|
|---|
| 8 |
root=`get_webserver_root` |
|---|
| 9 |
lynx=`get_http_downloader` |
|---|
| 10 |
|
|---|
| 11 |
bot_operator=`bot_operator` |
|---|
| 12 |
bot_operator_password=`bot_operator_password` |
|---|
| 13 |
# FIXME: put these in servers.xml config FIXME: currently they just hardcode over the above calls |
|---|
| 14 |
bot_operator="klaus_kinski" |
|---|
| 15 |
bot_operator_password="fuzzlebuzzle" |
|---|
| 16 |
|
|---|
| 17 |
# db auth: (from env) |
|---|
| 18 |
db_u=`get_database_user` |
|---|
| 19 |
db=`get_database_name` |
|---|
| 20 |
db_p=`get_database_password` |
|---|
| 21 |
|
|---|
| 22 |
# FIXME: put these into servers.xml |
|---|
| 23 |
time_to_wait_between_lists=3600 # in seconds |
|---|
| 24 |
emails_per_time_unit=225 # ISP limit is 250/ hour |
|---|
| 25 |
|
|---|
| 26 |
cd "$root/_mail" |
|---|
| 27 |
echo in `pwd` |
|---|
| 28 |
|
|---|
| 29 |
echo dumping list of users to notify: |
|---|
| 30 |
mysql -u $db_u -p$db_p $db -s -e 'SELECT userid FROM users WHERE snuffed IS NULL AND DISABLED = 1' > recipients.txt |
|---|
| 31 |
|
|---|
| 32 |
echo -n "splitting up the file into sub-lists to be mailed one per hour: " |
|---|
| 33 |
split -d -l $emails_per_hour recipients.txt recipient-batch- |
|---|
| 34 |
echo -n `ls -1 recipient-batch-* | wc -l` |
|---|
| 35 |
echo " sub-lists created" |
|---|
| 36 |
|
|---|
| 37 |
for sub_list in recipient-batch-* |
|---|
| 38 |
do |
|---|
| 39 |
echo processing sub-list $sub_list at `date` |
|---|
| 40 |
|
|---|
| 41 |
for user in `cat $sub_list` |
|---|
| 42 |
do |
|---|
| 43 |
$lynx --dump --auth="$bot_operator:$bot_operator_password" "http://feedmelinks.com/admin/disable-user?op=$op_flag&user=$user" > /dev/null |
|---|
| 44 |
sleep 1 |
|---|
| 45 |
done |
|---|
| 46 |
|
|---|
| 47 |
mv $sub_list "SENT-$sub_list" |
|---|
| 48 |
|
|---|
| 49 |
sleep $time_to_wait_between_lists |
|---|
| 50 |
done |
|---|
| 51 |
|
|---|