Choose style:

Author Topic: bash script to update and clean.  (Read 2198 times)

0 Members and 1 Guest are viewing this topic.

Offline AndyInMokum

  • Global Moderator
  • Hero
  • *****
  • Posts: 4808
  • Karma: 1013
  • "Keep on Rockin' in the Free World"
    • View Profile
  • Peppermint version(s): PM 9 & PM 8 Respin-2 (64-bit)
bash script to update and clean.
« on: November 14, 2014, 11:17:11 am »
Hi all, while I was having a dig around in the Crunchbang forums I found this little bash script to automatically update and clean one's system: bash update_and_clean script from Crunchbang.  There doesn't seem to be any serious complaints about it from the Crunchies.  It looks really interesting, although I don't fully understand the second part of it that involves cleaning up old kernels.  I was wondering if it was feasible to apply it to Peppermint or would there be a need for modifications to run it safely?
Backup! Backup! Backup! If you're missing any of these -  you ain't Backed Up!
For my system info please L/click HERE.

Offline PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 26082
  • Karma: 2842
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 10
Re: bash script to update and clean.
« Reply #1 on: November 14, 2014, 12:08:56 pm »
Without backwards engineering the awk commands I can't advise it......

All seemed well until I got to the kernel removal dry run, where it said it  build-essential and a ton of other packages would become redundant, and would be removed (not what should happen  :o )
Quote
The following packages were automatically installed and are no longer required: <-- this is what would become redundant if I'd carried on
  docbook-to-man gir1.2-gtk-2.0 intltool libavahi-client-dev
  libavahi-common-dev libcairo-script-interpreter2 libcupsfilters-dev
  libgnutlsxx27 libgpg-error-dev libgssrpc4 libharfbuzz-dev
  libharfbuzz-gobject0 libice-dev libieee1284-3-dev libjbig-dev
  libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-7 liblzma-dev libp11-kit-dev
  libpcrecpp0 libpixman-1-dev libsensors4-dev libsigc++-2.0-dev libsm-dev
  libssl-doc libtasn1-6-dev libtiffxx5 libtinfo-dev libv4l-dev libv4l2rds0
  libvte-2.90-doc libwayland-dev libwrap0-dev libxcb-render0-dev
  libxcb-shm0-dev libxcomposite-dev libxcursor-dev libxdamage-dev
  libxfixes-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev
  libxrender-dev python-mako python-markupsafe squashfs-tools
  x11proto-composite-dev x11proto-damage-dev x11proto-fixes-dev
  x11proto-randr-dev x11proto-render-dev x11proto-xinerama-dev xsltproc
The following packages will be REMOVED <--this what would actually have been removed, making the above redundant
  bcmwl-kernel-source build-essential comerr-dev g++ g++-4.8 gnome-common
  gobject-introspection gtk-doc-tools kernel-package krb5-multidev
  libatk-bridge2.0-dev libatk1.0-dev libatkmm-1.6-dev libc6-dev libcairo2-dev
  libcairomm-1.0-dev libcups2-dev libcupsimage2-dev libexif-dev libexpat1-dev
  libfontconfig1-dev libfreetype6-dev libgail-3-dev libgcrypt11-dev
  libgdk-pixbuf2.0-dev libglade2-dev libglib2.0-dev libglibmm-2.4-dev
  libgnutls-dev libgphoto2-dev libgtk-3-dev libgtk2.0-dev libgtkmm-2.4-dev
  libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libkrb5-dev libncurses5-dev
  libnotify-dev libpango1.0-dev libpangomm-1.4-dev libpcre3-dev libpng12-dev
  libpython-dev libpython2.7-dev libsane-dev libsnmp-dev libssl-dev
  libstdc++-4.8-dev libtiff5-dev libtool libvte-2.90-dev libxft-dev
  libxml++2.6-dev linux-headers-3.13.0-37 linux-headers-3.13.0-37-generic
  linux-headers-3.13.0-38 linux-headers-3.13.0-38-generic
  linux-headers-3.13.0-39 linux-headers-3.13.0-39-generic
  linux-image-3.13.0-37-generic linux-image-3.13.0-38-generic
  linux-image-3.13.0-39-generic linux-image-extra-3.13.0-37-generic
  linux-image-extra-3.13.0-38-generic linux-image-extra-3.13.0-39-generic
  linux-libc-dev python-dev python2.7-dev zlib1g-dev

Somewhat more than just the redundant kernels eh  :o

So there's obviously something wrong .. problem is I'm currently too drunk to figure it out  :-\  :D
« Last Edit: November 14, 2014, 12:19:41 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline AndyInMokum

  • Global Moderator
  • Hero
  • *****
  • Posts: 4808
  • Karma: 1013
  • "Keep on Rockin' in the Free World"
    • View Profile
  • Peppermint version(s): PM 9 & PM 8 Respin-2 (64-bit)
Re: bash script to update and clean.
« Reply #2 on: November 14, 2014, 05:43:24 pm »
Yeah, I see what you mean.  I said what the hell and ran it on my Crunchbang installation to test.  It works but is a bit too aggressive.  It took out Google Earth too.  No big deal, as it too about a minute to re-install - just saying!! 

I found this one instead that looks a lot mellower:
Spoiler (click here to view / hide)
#!/bin/bash

echo -n "# Update package index files "
apt-get update
echo -n "# Install updates "
apt-get dist-upgrade -y
apt-get upgrade -y
apt-get install -f
echo -n "# Remove unused packages "
apt-get autoclean
apt-get autoremove -y
apt-get clean

dpkg --purge `COLUMNS=300 dpkg -l "*" | egrep "^rc" | cut -d" " -f3`

echo -n "# Update script completed "
[close]

I was just thinking that running a script like this as a cron job periodically could help keep a system fine tuned.
Backup! Backup! Backup! If you're missing any of these -  you ain't Backed Up!
For my system info please L/click HERE.

Offline iamesperambient

  • Veteran
  • ****
  • Posts: 1269
  • Karma: 89
  • a totally awesome dude
    • View Profile
    • i AM esper (drone ambient music)
  • Peppermint version(s): Peppermint 8 64 bit
Re: bash script to update and clean.
« Reply #3 on: November 14, 2014, 11:36:06 pm »
im asking because im new to linux isn't doing something like removing an old kernel critical sometimes to your system
and can cause a lot of errors? i know it can bring back a lot of space but i hear if done incorrectly can mess things up pretty bad?
http://iamesper.bandcamp.com
boring drone music from NJ

Offline AndyInMokum

  • Global Moderator
  • Hero
  • *****
  • Posts: 4808
  • Karma: 1013
  • "Keep on Rockin' in the Free World"
    • View Profile
  • Peppermint version(s): PM 9 & PM 8 Respin-2 (64-bit)
Re: bash script to update and clean.
« Reply #4 on: November 15, 2014, 12:49:29 am »
The answer to that one is yes and no.  Old kernels are what they are - old.  However if you have a kernel update and things go pear shaped. It is good to have a tried and tested working kernel to fall back to until a patch or fix is made available for the new kernel.  For the vast majority of us, that is very unlikely to happen.  This is more likely to happen to the hard core crazies using Arch, Gentu, Linux From Scratch and such with new untested hardware etc.  I call them crazies because they get a warm fuzzy feeling when it all goes south and they can tinker with kernels ;D.  It start to get ridiculous for the rest of us sane people having a bunch of redundant kernels sitting around and taking up space.  This becomes more apparent if you are limited on your disk space. 

I saw these scripts in the Crunchbang forum and thought, "that's clever, I'll ask PCNetSpec what he thinks".  For me, I'm interested out of curiosity because I want to better learn how to write bash scripts and utilize them.  I'm still very much a novice and testing the water so to speak.  My hypothetical big toe is just about wet  :D.
« Last Edit: November 15, 2014, 12:51:33 am by AndyInMokum »
Backup! Backup! Backup! If you're missing any of these -  you ain't Backed Up!
For my system info please L/click HERE.

Offline iamesperambient

  • Veteran
  • ****
  • Posts: 1269
  • Karma: 89
  • a totally awesome dude
    • View Profile
    • i AM esper (drone ambient music)
  • Peppermint version(s): Peppermint 8 64 bit
Re: bash script to update and clean.
« Reply #5 on: November 16, 2014, 01:54:47 am »
anything seems worth  while if its safe and can clean up disk space, of course again i say the word safe because id rather
a little less space than everything gone south you know?
http://iamesper.bandcamp.com
boring drone music from NJ