User Tools

Site Tools


Sidebar

projects

ntr0 (due 20210203)
pct1 (bonus; due 20210203)
wcp1 (due 20210203)
ngf0 (due 20210210)
pct2 (due 20210210)
wcp2 (due 20210210)
adm0 (due 20210217)
pct3 (bonus; due 20210217)
wcp3 (due 20210217)
ngf1 (due 20210224)
pct4 (bonus; due 20210224)
wcp4 (due 20210224)
pbx0 (due 20210303)
pct5 (bonus; due 20210303)
wcp5 (due 20210303)
ngf2 (due 20210310)
gfo0 (due 20210310)
pct6 (due 20210310)
wcp6 (due 20210310)
pbx1 (due 20210317)
pct7 (bonus; due 20210317)
wcp7 (due 20210317)
ngf3 (due 20210324)
pct8 (due 20210324)
wcp8 (due 20210324)
pbx2 (due 20210331)
gfo1 (due 20210331)
pct9 (bonus; due 20210331)
wcp9 (due 20210331)
ngf4 (due 20210407)
pctA (due 20210407)
wcpA (due 20210407)
ldg0 (due 20210414)
pctB (bonus; due 20210414)
wcpB (due 20210414)
ngf5 (due 20210421)
pctC (due 20210421)
wcpC (due 20210421)
gfo2 (due 20210428)
pctD (bonus; due 20210428)
wcpD (bonus; due 20210428)
pctE (bonus; due 20210505)
wcpE (bonus; due 20210505)
EoCE (due 20210512)
haas:spring2021:unix:projects:ircbot

Corning Community College

CSCS1730 UNIX/Linux Fundamentals

~~TOC~~

Project: IRC BOT

Objective

To gain some familiarity with the task scheduling facilities on the system while exploring the obtaining, configuring, and deployment of a piece of software.

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, and run at a designated time or in reaction to a particular event.

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 Cron:

“Cron is a time-based job scheduler in Unix-like computer operating systems. The name cron comes from the word “chronos”, Greek for “time”. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration, though its general-purpose nature means that it can be used for other purposes, such as connecting to the Internet and downloading email.”

Be sure to check the manual page for cron(8), and the corresponding manual pages for crontab(1) and crontab(5). When you are familiar with where pertinent information can be found regarding cron, proceed to the question below.

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's an official Phenny
    • There's also a variant known as phenny_osu
  • 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, you'll want to keep in mind the following information:

  • 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: #botchan
  • 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/plugins

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, and there appear to be a few third-party sources, such as:

  • 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 (call it botkill.sh)
    • a text file called (at.txt) containing syntax used to create/deploy at job
    • a listing of your crontab entries (crontab.txt), showing the correctly scheduled deployment of your script
    • 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/plugins used (botdata.txt)
    • 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/handle, so it will not be confused with your project submission. If you want to schedule it, do so using a differently named script at a different time interval).

To submit this project to me using the submit tool, run the following command at your lab46 prompt:

$ submit unix ircbot ircbot.tar.bz2
Submitting unix project "ircbot":
    -> 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.

haas/spring2021/unix/projects/ircbot.txt · Last modified: 2014/03/10 14:02 by 127.0.0.1