This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
haas:spring2014:unix:projects:ircbot [2014/03/10 13:16] – created wedge | haas:spring2014:unix:projects:ircbot [2014/03/10 14:02] (current) – [Task 1: Obtain irc bot] wedge | ||
---|---|---|---|
Line 9: | Line 9: | ||
=====Objective===== | =====Objective===== | ||
+ | To gain some familiarity with the task scheduling facilities on the system while exploring the obtaining, configuring, | ||
+ | |||
+ | =====Background===== | ||
+ | To most of us, computers are a frequently used interactive tool for accomplishing work. With our recent explorations into the realm of shell scripting, concepts of automation are starting to enter our peripherary. | ||
+ | |||
+ | With automation, comes the need to do things outside that interactive environment, | ||
+ | |||
+ | We will be scheduling tasks with respect to time in this project, to get better acquainted with the functionality and capabilities of non-interactive yet automated tasks. | ||
+ | |||
+ | =====cron===== | ||
+ | From the wikipedia article on [[wp> | ||
+ | |||
+ | "Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word " | ||
+ | |||
+ | Be sure to check the manual page for **cron**(**8**), | ||
+ | |||
+ | =====Task 1: Obtain irc bot===== | ||
+ | There exist a number of irc bots, consisting of varying features and complexities. To facilitate your task, I would recommend the using of Phenny (or a clone), which tends to be simpler to deploy than its more configurable counterparts. | ||
+ | |||
+ | So, via the proper means: | ||
+ | |||
+ | * Download a recent release of Phenny (check out **wget**, it is a nifty tool) | ||
+ | * There' | ||
+ | * There' | ||
+ | * If it is obtained in archive form, extract it somewhere within your home directory (perhaps under **src/**) | ||
+ | * Take a look at the files obtained, start reading any documentation | ||
+ | |||
+ | =====Task 2: Configure irc bot===== | ||
+ | An irc bot, being a network-aware piece of software, needs sufficient configuration in order to operate properly. While it is up to you to derive a working configuration, | ||
+ | |||
+ | * irc handles are limited to 9 characters max (and they may not like starting with numbers or having spaces in them) | ||
+ | * the irc server you want to connect to is: **irc.offbyone.lan** (port 6667 if it matters) | ||
+ | * you may want to initially configure your bot to join a secluded channel so you can test it. For the project, it will ultimately need to join: **# | ||
+ | * you should configure both yourself and me (username **wedge**) as administrators for the bot. | ||
+ | |||
+ | Verify you can successfully start the bot and that it connects to the intended server and channel. You may want to run it in a sub-console in your screen session, so that you can keep an eye on any messages it generates. | ||
+ | |||
+ | =====Task 3: Enhance the bot with modules/ | ||
+ | In addition to core usability, I'd like you to enable additional functionality through the use of modules. A few modules come with the stock Phenny software distribution, | ||
+ | |||
+ | * phenny-games | ||
+ | * oblique | ||
+ | |||
+ | Install and enable modules for your bot, and verify some form of functionality. | ||
+ | |||
+ | **NOTE:** Due to changes in the service it uses, the Phenny **weather** module is beyond broken. Trying to use it will result in an error being displayed. If you are skilled with Python and can craft a solution, that can certainly count toward completing this task of the project. | ||
+ | |||
+ | =====Task 4: Script to check bot status===== | ||
+ | Using tools and concepts we learned previously, especially: | ||
+ | |||
+ | * ps | ||
+ | * grep | ||
+ | * pgrep | ||
+ | |||
+ | Write a script that checks for a currently running Phenny instance (run by you). If not instance is found, launch a new instance. If an instance IS running, do nothing. | ||
+ | |||
+ | Be sure to make use of **absolute paths**. | ||
+ | |||
+ | =====Task 5: Script to kill running bot===== | ||
+ | Using tools and concepts we learned previously, especially: | ||
+ | |||
+ | * ps | ||
+ | * grep | ||
+ | * pgrep | ||
+ | * kill | ||
+ | * pkill | ||
+ | |||
+ | Create a script that will check for a currently running Phenny instance (run by you). If an instance is running, kill it. | ||
+ | |||
+ | If no instance is running, do nothing. | ||
+ | |||
+ | =====Task 6: Create a cron job===== | ||
+ | Reading up on cron and figuring out how to add an entry to your user's personal crontab, add a job that runs your check script (Task 4 script) every 10 minutes. | ||
+ | |||
+ | You can verify successful cron job deployment by ensuring your bot is not running and waiting for the next 10 minute marker and see if it starts. | ||
+ | |||
+ | =====Task 7: Create an at job===== | ||
+ | While cron is used for long-term scheduled jobs, **at** is useful for short term ones. | ||
+ | |||
+ | Read up on **at**, and deploy an **at** job that will run your **botkill** script (task 5) a couple minutes before a 10 minute marker. | ||
+ | |||
+ | Use this to test both your script and correct usages of **at**, as well as the **cron**-related activities. | ||
+ | |||
+ | =====Submission===== | ||
+ | To successfully complete this project, the following criteria must be met: | ||
+ | |||
+ | * All criteria indicated above | ||
+ | * To signal completion, submit an archive containing the following files: | ||
+ | * botcheck script (call it **botcheck.sh**) | ||
+ | * botkill script | ||
+ | * a text file called (**at.txt**) containing syntax used to create/ | ||
+ | * a listing of your crontab entries (**crontab.txt**), | ||
+ | * a copy of your configured bot's config file (**config.py**) | ||
+ | * a text file containing the URL you downloaded your bot, along with any URLs you obtained modules/ | ||
+ | * Put all these files in a **tar** archive | ||
+ | * Compress it with max compression using **bzip2** | ||
+ | * Name the archive **ircbot.tar.bz2** | ||
+ | * After you've recorded the crontab entry with your botcheck script, remove the entry from your crontab (so we don't end up with a bunch of phantom bots nobody cares about). | ||
+ | * When you're done with this project, kill your bot. Do not leave it running. | ||
+ | |||
+ | **NOTE:** If this activity fascinates you and you'd like to keep playing with your bot, do so using a different config/ | ||
+ | |||
+ | To submit this project to me using the **submit** tool, run the following command at your lab46 prompt: | ||
+ | |||
+ | <cli> | ||
+ | $ submit unix ircbot ircbot.tar.bz2 | ||
+ | Submitting unix project " | ||
+ | -> ircbot.tar.bz2(OK) | ||
+ | |||
+ | SUCCESSFULLY SUBMITTED | ||
+ | </ | ||
+ | |||
+ | You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches. |