Release A few of my scripts

Forum rules
Before you post please read this

Release A few of my scripts

Postby crosenblum on Mon Apr 23, 2012 4:27 pm

Some of these I created from scratch, other's I took from other os's and implemented them here.

fix_public_keys.sh - This takes a perl script that was released here to find and import public key's for repositories, i just made it all into a bash script that could be automated.
Code: Select all
#!/bin/bash
#fix gg errors with missing public keys
#http://forums.linuxmint.com/viewtopic.php?f=42&t=31980

#variables
dir="$HOME/gpg-fix"

#step 1. if folder does not exist create it
if [ ! -d "$dir" ]; then

   #go to home folder
   cd $HOME

   #create folder
   mkdir gpg-fix

fi

#step 2. Download a new copy of the perl script

#change to the fix folder
cd gpg-fix

#download the perl script in compressed tar.gz format
wget http://savvas.radevic.com/launchpad/change.tar.gz -O change.tar.gz

#untar the file to the current folder
tar xzvf change.tar.gz

#step 3. run perl script
perl ./*.pl

#step 4. return to home folder
cd $HOME

#step 5. exit
exit


update_ifilter.sh - Grabs the ipfilter.dat from bluetack which hosts a wide variety of ip block lists, and then put's it in the qbittorrent folder, but you can easily change what folder that is for.
Code: Select all
#!/bin/bash

#setup variables
tempfolder=$HOME/Downloads
httpsite=http://www.bluetack.co.uk/config
httpfile=nipfilter.dat.gz
httpfileuncompressed=nipfilter.dat
blocklist=ipfilter.dat

echo.
echo -------------------------------------
echo         qBittorrent Blocklist Updater
echo
echo                           version 1.0
echo         Written by Craig M. Rosenblum
echo -------------------------------------
echo .
echo ::**:: Creating temp folder and removing files

#check if tempfolder exists if not create it
if [ ! -d "$tempfolder" ]; then
   mkdir $tempfolder
fi

#delete existing httpfile and blocklist files
if [ -d "$tempfolder/$httpfile" ]; then
   rm "$tempfolder/$httpfile"
fi

if [ -d "$tempfolder/$blocklist" ]; then
   rm "$tempfolder/$blocklist"
fi



#download the ipfilter to a local folder
echo ::**:: Downloading the blocklist
wget --no-verbose --quiet "$httpsite/$httpfile" --no-cache -O "$tempfolder/$httpfile">/dev/null

#check for wget errors
if [ $? -ne 0 ]; then
   echo ::**::        wget returned errorlevel: $?
   echo ::**:: An error occured!
   exit 1
fi

#delete previously unzipped ipfilter file
if [ -d "$tempfolder/nipfilter.dat" ]; then
   rm "$tempfolder/nipfilter.dat"
fi

#unzip the downloaded file
echo ::**:: Uncompressing "$httpfile" to "$httpfileuncompressed"
gunzip -f "$tempfolder/$httpfile"

if [ $? -ne 0 ]; then
   echo ::**::        gunzip returned errorlevel: $?
   echo ::**:: An error occured!
   exit 1
fi

#rename the downloaded blocklist file
echo ::**:: Moving and renaming the blocklist from "$httpfileuncompressed" to "$blocklist"
mv -f "$tempfolder/$httpfileuncompressed" "$HOME/.config/qBittorrent/$blocklist"

if [ $? -ne 0 ]; then
   echo ::**::        rename returned errorlevel: $?
   echo ::**:: An error occured!
   exit 1
fi


echo ::**:: Update Complete!
exit 0


gcal_synch.sh - This help's download on a regular basis a ical formatted version of my google calendar, so that Rainlendar can display my current schedule
Code: Select all
#!/bin/bash
#setup wget variables
URL="https://www.google.com/calendar/ical/youraccount/basic.ics"
dir1="$HOME/Downloads"
dir2="$HOME/Scripts"

echo .
echo -------------------------------------
echo               Google Calendar Updater
echo
echo                           version 1.0
echo         Written by Craig M. Rosenblum
echo -------------------------------------
echo .

#download the ipfilter to a local folder
echo ::**:: Downloading the google calendar to $dir2/basic.ics
wget -c -N --no-check-certificate $URL -o "$dir1/basic.ics" >/dev/null

#mv file to new destination
echo ::**:: Moving basic.ics to downloads folder
mv -f "$dir2/basic.ics" "$dir1/basic.ics"

echo ::**:: Download Complete!
exit 0


change_wallpaper.sh - I wasn't able to get any wallpaper app to work, so i created a bash script to randomally grab a wallpaper from my stored wallpapers and set it as my wallpaper, plus it does a notify to let me know the wallpaper has changed
Code: Select all
#!/bin/bash

# Script to randomly set Background from files in a directory

# Directory Containing Pictures
DIR="your wallpaper folder"

# Command to Select a random jpg file from directory
# Delete the *.jpg to select any file but it may return a folder
PIC=$(ls "$DIR"/*.jpg | shuf -n1)

# Command to set Background Image
mateconftool-2 -t string -s /desktop/mate/background/picture_filename "$PIC"

#send notification message that a wallpaper changed
notify-send -i 'dialog-information' 'Changing Wallpaper' "$PIC";
exit


I am working on some other bash scripts, to help automate my renaming, moving, of movies and tv shows.

I really loved automating things, via window's batch scripts, and now am learning to love to do the same in linux.

I hope you enjoy any of these...

Craig
crosenblum
Level 1
Level 1
 
Posts: 40
Joined: Fri Apr 06, 2012 10:53 am

Linux Mint is funded by ads and donations.
 

Re: Release A few of my scripts

Postby crosenblum on Mon Apr 23, 2012 7:53 pm

any comments or thoughts anyone?

Any suggestions for improvements?
crosenblum
Level 1
Level 1
 
Posts: 40
Joined: Fri Apr 06, 2012 10:53 am

Re: Release A few of my scripts

Postby Burrito on Wed May 02, 2012 3:51 pm

Some nice scripts. I know I've needed the first one for a while. I've already obtained a wallpaper script from somewhere else on the forum, and modified it to change the wallpaper every 6 hours and wait in between (probably better practice to make it a cron job though).

With the wallpaper script, I've got some PNG's in my wallpaper folder. So I modified the *.jpg part to *.*p*g. That matches both jpg/jpeg, and png, and probably a couple of other extensions. There is probably a better way.
Burrito
Level 1
Level 1
 
Posts: 32
Joined: Sat Mar 10, 2012 9:59 pm


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 3 guests