LinuxGurl

I wrote this script out of my need for a quick method of adding virtual domains. I hope you find this to be of great use.

create a file named addomain

  1. sudo vim /usr/bin/adddomain

Place this in your file:

  1. #!/bin/bash
  2. #Edit the following e-mail address:
  3. email="your@email.address"
  4. ipaddress=`ifconfig eth0 | grep inet | awk ‘{print $2}’ | sed ’s/addr://’ | grep .`
  5. domain=$1
  6. file="/etc/apache2/sites-available/$domain"
  7. if [ -z $domain ]; then
  8.         echo "You did not specify a domain"
  9.         echo "Usage:"
  10.         echo "          adddomain domain.tdl"
  11.         echo ""
  12. else
  13.         ping=`ping -c 1 $domain|grep "$ipaddress"`
  14.         if [ -z $ping ]; then
  15.                 echo "$domain is not hosted on this server, or you have not set up its A record"
  16.         else
  17.                 touch /etc/apache2/sites-available/$domain;
  18.                 echo "# Place any notes or comments you have here
  19. # It will make any customisation easier to understand in the weeks to come
  20. # domain: $domain
  21. # public: /var/virtualwww/$domain
  22.  
  23. <VirtualHost *:80>
  24.  
  25.  # Admin email, Server Name (domain name) and any aliases
  26.  ServerAdmin $email
  27.  ServerName  $domain
  28.  ServerAlias www.$domain
  29.  
  30.  
  31.  # Index file and Document Root (where the public files are located)
  32.  DirectoryIndex index.php
  33.  DocumentRoot /var/virtualwww/$domain
  34.  
  35.  
  36.  # Custom log file locations
  37.  LogLevel warn
  38.  ErrorLog  /var/log/apache2/$domain/error.log
  39.  CustomLog /var/log/apache2/$domain/access.log combined
  40.  
  41. </VirtualHost>" > $file;
  42.                 mkdir /var/log/apache2/$domain;
  43.                 mkdir /var/virtualwww/$domain;
  44.                 ln -s /var/www/.htaccess /var/virtualwww/$domain/.htaccess;
  45.                 mkdir /var/virtualwww/$domain/cgi-bin;
  46.                 echo "created $domain";
  47.                 echo "please restart apache2";
  48.                 a2ensite $domain;
  49.         fi
  50. fi

Next, change the permissions of adddomain:

  1. sudo chmod 500 /bin/bash/adddomain

Once all that is done, create a new folder to house your virtual domains:

  1. sudo mkdir /var/virtualwww

Next, change the adddomain file so it properly points to your .htaccess file (if you have one), and you’re done. To use this script:

  1. adddomain domain.tdl

The server will do a lookup on that domain/subdomain, and if it shows that the server you are on does not have an IP on it that matches the (sub)domains IP, it won’t let you add that site.

Twitter for BASH

23rd June 2009

Thanks Linux Journal for this one:

Ok, You’re REALLY into Twitter, and you want a faster way to tweet, or you’re frustrated at having to hunt through the log files, and you want to share that frustration with all your tweetererers.  Here’s a great way:

First, you’ll need to do one of 2 things: create a ~/bin folder, or have root access so you can add a new file to your /usr/bin folder.  The 2nd way will allow for multiple-user capabilities.  I’ll cover the first way, and move on to the mods you’ll need to make to do the 2nd one.

create a folder in your home root (~) called bin

  1. user@computer:~# mkdir bin

now go to that folder:

  1. cd bin

and edit a new file, called tweet:

  1. vim tweet

copy and paste the following into that file (press “i” before you try to paste into vim):

  1. #!/bin/sh
  2. # tweet – command line twitter interface
  3. user="USERNAME_HERE"; pass="PASS_HERE"
  4. msg=$(echo $@ | sed ’s/+/%2B/g;s/ /+/g’)
  5. curl –silent –user "$user:$pass" –data-ascii \
  6.   "status=$msg" "http://twitter.com/statuses/update.json" \
  7.   > /dev/null

Change “USERNAME_HERE” and “PASSWORD_HERE” to your twitter user name and password, respectivly.  Hit ESC and then type

  1. :wq

don’t forget to hit the colon (:) and hit enter

Now, type this from the shell:

  1. chmod o+x tweet

Ok, now we need to make sure you have curl:

  1. which curl

if it tells you a path (/usr/bin/curl, or something like that), you’re ok. Otherwise install it using your package manager.  Mine is apt-get

  1. apt-get install curl

Once that’s installed, you can simply run tweet from bash:

  1. tweet "Hello, world!"

To make this a multi-user feature, just move the file from ~/bin to /usr/bin:

  1. sudo mv bin/tweet /usr/bin/tweet;sudo chmod a+x /usr/bin/tweet

Next, modify tweet so it looks like this:

  1. #############################################################
  2. #!/bin/sh
  3. # tweet – command line twitter interface
  4.  
  5. . ~/.tweetCreds
  6.  
  7. msg=$(echo $@ | sed ’s/+/%2B/g;s/ /+/g’)
  8. curl –silent –user “$user:$pass” –data-ascii \
  9. status=$msg” “http://twitter.com/statuses/update.json” \
  10. > /dev/null
  11. ################################################################

Next, make sure each user has a .tweetCreds, and that they look something like this (change credentials to suit each users Twitter credentials):

  1. user=”USERNAME”
  2. pass=”PASSWORD”

and finally, change the .tweetCreds permissions:

  1. chmod 600 ~/.tweetCreds

~JonsJava
(thanks Jerry for the multi-user bit)

All things *nix

16th May 2009

Hello, I’m JonsJava — LinuxGurls hubby.  I just wanted to write a post to let everybody know the future of this site.  LinuxGurl will still be posting regularly, but we have 2 new contributors.  They are both knowledgeable about the topics that they will be discussing.  I will also begin making posts about open source products, and the path some of the larger projects/foundations are taking, and my view on the future in regards to their new direction.    I will also be shamelessly making plugs for my open-source products, so I hope you like PHP apps.  If you have any questions, feel free to hit me up on my webiste, and I’ll do my best to answer them. If you have an open-source(driven) product you would like to have evaluated and reviewed, just hit up my wife.

~JonsJava

Yep, I decided to share my Conky setup with the world because I have scoured several pages of different forums and websites trying to get mine just right.
It all started with a simple stumble upon this page which is what I used for my base layout a few months ago. I decided I wanted more a few days ago and got to work…
I found this thread which links to another thread, and between them, they have over 7000 posts! That’s a lot to go through….
Assuming you already have Conky installed (and if not, you at least know where to go download it), here are all the files that go along with my Conky set-up.
.conkyrc
# Conky configuration
 
background yes
use_xft yes
xftfont Sans:size=8
xftalpha 0.8
update_interval 5.0
total_run_times 0
own_window yes
own_window_type override
own_window_transparent yes
#own_window_colour black
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
border_margin 2
border_width 1
default_color white
default_shade_color black
default_outline_color black
alignment middle_right
gap_x 12
gap_y 0
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
use_spacer none
show_graph_scale no
show_graph_range no
text_buffer_size 1024
color1 333333
color2 000000
color3 FFFFFF
color4 AAAAAA
color5 FFA500
 
# stuff after 'TEXT' will be formatted on screen
 
TEXT
${font Domestic Manners:style=Bold:size=30}${color5}SuzyQ's PC
${voffset -50}${color3}$stippled_hr
${voffset -45}${font Sans:style=Bold:size=8}CURRENT CONDITIONS${hr 2}
${execpi 300 conkyForecast --location=XYZXYZ --template=$HOME/.conkyForecast.template}
${font Sans:style=Bold:size=8}SYSTEM${hr 2}
${font}Hostname: $alignr$nodename
Kernel: $alignr$kernel
Uptime: $alignr$uptime
Processes: ${alignr}$processes ($running_processes running)
Load: ${alignr}$loadavg
 
${font Sans:style=Bold:size=8}FILESYSTEM AND MEMORY${hr 2}
${font}Root: ${fs_free /} / ${fs_size /}
${fs_bar 4 /}
Home: ${fs_free /home} / ${fs_size /home}
${fs_bar 4 /home}
 
${font Sans:style=Bold:size=8}CPU1: ${font}${cpubar cpu1 10,150} ${cpu cpu1}%
${font Sans:style=Bold:size=8}CPU2: ${font}${cpubar cpu2 10,150} ${cpu cpu2}%
 
${font Sans:style=Bold:size=8}RAM: ${font}${mem} / ${memmax} (${memperc}%)
${membar 4}
${font Sans:style=Bold:size=9}SWAP: ${font}${swap} / ${swapmax} (${swapperc}%)
${swapbar 4}
 
${font Sans:style=Bold:size=8}PROCESSES${hr 2}
${font Sans:style=Bold:size=8}NAME $alignr PID CPU MEM
${voffset -5}${hr 1}
${font}${top name 1} $alignr${top pid 1} ${top cpu 1} ${top mem 1}
${top name 2} $alignr${top pid 2} ${top cpu 2} ${top mem 2}
${top name 3} $alignr${top pid 3} ${top cpu 3} ${top mem 3}
${top name 4} $alignr${top pid 4} ${top cpu 4} ${top mem 4}
${top name 5} $alignr${top pid 5} ${top cpu 5} ${top mem 5}
 
${font Sans:style=Bold:size=8}NETWORK${hr 2}
${font Sans:style=Bold:size=8}IP Address: ${font}${gw_ip}
${font Sans:style=Bold:size=8}Total Download: ${font}${totaldown eth0}
${font Sans:style=Bold:size=8}Total Upload: ${font}${totalup eth0}
${font Sans:style=Bold:size=8}Up Speed: ${font}${upspeed eth0} Kb/s ${font Sans:style=Bold:size=9}Down Speed: ${font}${downspeed eth0} Kb/s
 
${font Sans:style=Bold:size=8}TO DO LIST${hr 2}
${font}${execi 30 cat $HOME/.TODO.txt}

for more information about seting up your weather.com xml account, please click here

.conkyForecast.template
${voffset 0}${font ConkyWeather:size=20}[--datatype=WF] ${font Sans:size=10}${voffset -5}[--datatype=CT] -- [--datatype=CN], [--datatype=CO]
${font}Temperature:$alignr [--datatype=HT --imperial] (Feels Like [--datatype=LT --imperial])
Humidity:$alignr [--datatype=HM]
Visibility:$alignr [--datatype=VI --imperial]
Wind:$alignr [--datatype=WD --imperial] ([--datatype=WS --imperial])
UV-Index:$alignr [--datatype=UI] ([--datatype=UT])
Sunrise:$alignr [--datatype=SR]
Sunset:$alignr [--datatype=SS]
Barometer Tendency:$alignr [--datatype=BD]

.conkyForecast.config
# config settings for conkyForecast.py
CACHE_FOLDERPATH = /tmp/
CONNECTION_TIMEOUT = 5
EXPIRY_MINUTES = 30
TIME_FORMAT = %H:%M
DATE_FORMAT = %Y-%m-%d
LOCALE = en
XOAP_PARTNER_ID = your_partner_id
XOAP_LICENCE_KEY = your_licence_key

the following script was written because Conky had problems loading at the same time as Compiz, so I created the script so that Conky will load 20 seconds after start-up
.conky_start.sh
#!/bin/bash
sleep 20 && conky;

and after all that code, this is what I see whenever I log in. :)
conky_05142009

Tags: , ,

The Sun has Set

20th April 2009

  OO2mysql2 virtualbox

In case you’ve been in a box the past few days, Oracle has bought out Sun Microsystems.  While it may not seem like a big deal to some of you, you may not realize just how much Sun has contributed to the open source community, and that does not just apply to Linux users.

If you ask a poor college student (I’m just assuming most college students are poor, because when I went to college I was poor, and most of my friends were as well) and they are honest about where they get their software from, they are using Open Office to type up their term paper, rather than downloading a pirated version of Microsoft Office (then again, I’m assuming college students are honest).

I know that the average person does not have boatloads of money to spend on software, and that’s where Open Office gets its appeal. It’s free to download, and it doesn’t matter what platform you’re using it on: it just works, and it’s standards compliant.

If you have a website, and you’re not using ASP.NET (or any .net platform), you’re most likely using MySQL – that is if you’re not stuck in Web 1.0 and using HTML only.  MySQL is a simple, easy-to-use solution for storing data dynamically (memory-resident, rather than flat file).  It’s free, and has a great user base.

If you’ve ever wanted to try out a new OS without having to burn a CD, reboot your computer or *gasp* repartition your hard drive, you’ve most likely used a virtualization program.  VirtualBox is one of the most user (and novice)-friendly virtualization applications out there.  I know, because I’ve been using it since I found out other distributions of Linux besides my own offer live CDs to try out.  It makes giving a new distro a test drive simple.

Why have I been praising these 3 seemingly unrelated programs?  Because they have all been offered to us free over the years, and they are all currently owned by Sun Microsystems.  Now that Sun has been bought out, it doesn’t seem like these programs will be offered free to the masses any more.  I can almost guarantee that MySQL will be going the way of the Dodo. MySQL is going to be nothing more than a redundancy in a corporation that is built around a bloatware has-been of a SQL solution.

Farewell Sun, it was great while you were the big guy.  We will miss you.

SunM~LG and JonsJava

Older Posts »