one of many in the wild, wild net.
O C K E T S . N E T » Posts in 'Programming' category

Look! 1 comment

Made this in 45 mins. Alvin. :D

-- AVShouter
function lib:AVShouter()
local tradechan, msg;
msg = nil;
if GetNumRaidMembers() == 0 then
-- starting AV raid
msg = "Starting AV Premade. Have Enabler, be 70, follow directions, and open quickly. PST";
elseif GetNumRaidMembers() < 40 then
-- filling open AV raid
local rl, rotable;
rotable = {};
for raidMember=1,GetNumRaidMembers(),1 do
name, rank = GetRaidRosterInfo(raidMember)
if rank == 2 then rl = name end;
if rank == 1 then table.insert(rotable, name) end;
end
msg = "LFM AV Premade ("..rl.."). Have Enabler, be 70, follow directions, and open quickly. "..(40-GetNumRaidMembers()).." spots remaining.";
msg = msg.." PST ";
msg = msg..rl;
for i, v in ipairs(rotable) do
if i == # rotable then
if i == 1 then
msg = msg.." or "..v;
else
msg = msg..", or "..v;
end
else
msg = msg..", "..v;
end;
end
msg = msg.." for invite.";
end
if msg then
SendChatMessage(msg,"CHANNEL" ,nil , GetChannelName("Trade - City"));
else
DEFAULT_CHAT_FRAME:AddMessage("Raid is full dumbass.");
end
end
LibStub("AceConsole-3.0"):RegisterChatCommand("omavs", lib.AVShouter);
-- end AVShouter

Requires AceConsole-3.0 and LibStub

My first script 1 comment

So I’ve been dicking around with my linux ubuntu server. I installed postfix and courier-imap to set up an IMAP server on my network so whenever I feel like switching email clients I don’t lose all my mail. Well, the first thing I apparently have to do is make sure postfix is working right, and that involves configuring my /etc/postfix/main.cf file.

So I start looking into it, and come to a part where I have to list my external IP address as part of the config file so some kind of loop doesn’t happen. Well… how do I automate this? Here’s the script I eventually came up with:

sed ’s/^proxy_interfaces = .*$/proxy_interfaces = ‘`wget -qO- http://checkip.dyndns.org | html2text | cut -c21-35`’/’ /etc/postfix/main.cf > /etc/postfix/main.cf.tmp

mv /etc/postfix/main.cf /etc/postfix/main.cf.old

mv /etc/postfix/main.cf.tmp /etc/postfix/main.cf

/etc/init.d/postfix restart > /dev/null

I know it doesn’t show up right, but the first line starts from sed and ends with “> /etc/postfix/main.cf.tmp”, and what it does is query that web address which returns my IP as seen from the outside, then replaces the string “proxy_interfaces = blah blah blah” with a correct string that states what my IP address is from the outside. Anyway, I stuck this script in my cron.hourly folder so each hour it gets my external IP and updates my postfix main.cf file accordingly, rebooting my postfix daemon silently after each update.

I know my Linux kung-fu is weak, but I consider this a step towards mastery of my OS.

Today: shell scripts. Tomorrow: kernel programming… again! Just call it the “re-education of TJ O”

-TJ

Top of page / Subscribe to new Entries (RSS)