Script library (need help with these scripts)

Forum rules
Before you post please read this

Script library (need help with these scripts)

Postby wei2912 on Sun Aug 28, 2011 5:41 am

Welcome to the script library! Go to http://db.tt/Gg4GRId to download the scripts. More scripts will be added over time.

Download the launcher script first, then download other scripts. Please try out the scripts before removing them. You are recommended to download all scripts.

HELP NEEDED:
# - A backup script
# - More... help to brainstorm.

Will be adding more stuff. Anyway, for the moment, there are 2 functions:
1. Update your programs
2. Clean up Linux Mint

Future functions:
1. Speedup (version 1.3)
2. Backup (unknown...)

Changelog:

# Version 1.0
###### Config.sh ######
# Added update and clean function

# Version 1.1
###### Config.sh ######
# Added update grub to update function
# Added an infinite loop
# Cleaner interface (for editing)
# Commands from apt-get commands are still not removed, sorry. I tried using Vincent Vermeulen's command but it failed.
# Attempted sudo startup failed - trash cleanup did not work as the user was recongnised as root.

# Version 1.2
###### Config.sh ######
# clean function moved to Cleaner.sh
# apt-get commands are finally removed! Thanks to Vincent Vermeulen for providing the parameter.

###### Cleaner.sh ######
# Clean function added
# apt-get commands are finally removed! Thanks to Vincent Vermeulen for providing the parameter.

###### All ######
# Info option for scripts is added.
# Terminal screen is made clearer.

#Version 1.3 - Future version
###### Cleaner.sh ######
# Added speedup function

Please try these scripts and if you find any bug in them or a function you would like to include, please make a post in this topic.
Last edited by wei2912 on Thu Sep 01, 2011 2:50 am, edited 8 times in total.
wei2912
Level 2
Level 2
 
Posts: 79
Joined: Thu Jun 02, 2011 1:00 am

Linux Mint is funded by ads and donations.
 

Re: A script to update and clean up your OS and more (need h

Postby xenopeek on Sun Aug 28, 2011 6:05 am

I suggest you force the user of the script to run it as root or with sudo, so you don't have to litter your script with sudos:
Code: Select all
if [ `whoami` != root ]; then
    echo Please run this script as root or using sudo
    exit
fi

Infinite loop:
Code: Select all
updatefunc() {
# update code goes here
}
cleanfunc() {
# cleaning code goes here
}
while true; do
  echo
  echo "Choose your option. Type the number of your selection."
  echo "  1. Update my programs."
  echo "  2. Clean up my Linux Mint installation."
  echo "  0. Exit"

  read ans
  case $ans in
    1)
    updatefunc
    ;;
    2)
    cleanfunc
    ;;
    0)
    exit
    ;;
  esac
done

Shoving all output into the black hole:
Code: Select all
some_command > /dev/null 2>&1

But I suggest you replace > /dev/null with >> logfile, so you can read that if something borks. And if you are hiding the output, I suggest you check the exit status of the commands (in variable $?) in your script, so you can alert the user if something didn't work.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14996
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: A script to update and clean up your OS and more (need h

Postby wei2912 on Sun Aug 28, 2011 6:44 am

Thanks. Updated the script, however i could not make the script run as root as if i did so, the user will be recognized as root. Also, the command you gave me did not work for me - the apt-get output still appeared.
wei2912
Level 2
Level 2
 
Posts: 79
Joined: Thu Jun 02, 2011 1:00 am

Re: A script to update and clean up your OS and more (need h

Postby xenopeek on Sun Aug 28, 2011 7:03 am

wei2912 wrote:Thanks. Updated the script, however i could not make the script run as root as if i did so, the user will be recognized as root. Also, the command you gave me did not work for me - the apt-get output still appeared.

Well, I use the "check for root" lines regularly. You then run the script with sudo instead of normally, else it gives the error. I should put it at the top with the #!/bin/bash line. Never failed on me...

If > /dev/null 2>&1 doesn't work, read the manpage of apt-get (or other command) to see how to silence it. For apt-get:
-q, --quiet
Quiet; produces output suitable for logging, omitting progress
indicators. More q's will produce more quiet up to a maximum of 2.
You can also use -q=# to set the quiet level, overriding the
configuration file. Note that quiet level 2 implies -y, you should
never use -qq without a no-action modifier such as -d, --print-uris
or -s as APT may decided to do something you did not expect.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14996
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Scripts to help your OS (need help)

Postby wei2912 on Mon Aug 29, 2011 2:56 am

Thanks, it worked for me. Just released version 1.2
wei2912
Level 2
Level 2
 
Posts: 79
Joined: Thu Jun 02, 2011 1:00 am

Re: Script library (need help with these scripts)

Postby Pilosopong Tasyo on Sun Sep 04, 2011 8:11 am

Cleaner.sh, GetScripts.sh and PackagesConfig.sh
lines 9-12:
Code: Select all
case $response in
   *)
   ;; #End
esac

Remove the above block. It doesn't serve any useful purpose. AKA dead code.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1181
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Script library (need help with these scripts)

Postby wei2912 on Sun Oct 30, 2011 6:00 am

Sorry, i abandoned the scripts. I am currently working on a Java cleaner, so if you are interested in cleaning your OS, give me a PM and i will respond.

*** Administrators, can you help to lock this thread? Thanks. ***
wei2912
Level 2
Level 2
 
Posts: 79
Joined: Thu Jun 02, 2011 1:00 am

Re: Script library (need help with these scripts)

Postby rich_roast on Sun Oct 30, 2011 5:39 pm

Op's wish followed.
User avatar
rich_roast
Level 6
Level 6
 
Posts: 1136
Joined: Sat Sep 05, 2009 4:37 pm

Linux Mint is funded by ads and donations.
 

Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 2 guests