Showing posts with label FreeBSD. Show all posts
Showing posts with label FreeBSD. Show all posts

Wednesday, January 30, 2019

A few new one-liners

I like to automate and/or simplify* a lot of processes that I run on my stuff here are a few I am posting for the sake of having them somewhere

FreeBSD Updates

cd /usr/ports/ ; df -hl ; pkg update ; pkg clean -y ; portsclean -C -D -DD -L -P -PP ; df -hl ; portsnap fetch update ; pkg version -vIL= | awk '{print $1}' | sed 's/-[0-9].*//g' | awk '{printf "%s"" ",$0}' | sed 's/^/portmaster -P -y --no-confirm -D /g' | sh ; pkg version -vIL= ; pkg audit -F ; df -hl

Requires portmaster and portupgrade to be installed and prefers ports over pkg - what can I say I hate myself

CentOS Updates

clear; yum clean all; rm -rf /var/cache/yum; yum -y upgrade --skip-broken; package-cleanup --problems; package-cleanup --dupes; rpm -Va --nofiles --nodigest;
I think this requires yum-utils be installed to do the cleaning bits

Debian Updates (also obviously works on Ubuntu)

clear; apt-get update ; apt-get upgrade ; apt-get dist-upgrade; apt-get autoclean;  apt-get autoremove
OpenBSD Updates

I cheat and use openup, a currently free service provided by mtier - more information can be find by going to https://www.mtier.org/solutions/apps/openup/


* so yeah that FreeBSD one isn't "simple" but it does a bunch of stuff I need it to do.

Feel free to use these or whatever, I don't really care.

Thursday, March 21, 2013

FreeBSD Update Script



This is a script I stole from someone else and modified.
It originally used portupgrade, but portmaster is better in my opinion.
The script basically looks for all out of date ports and runs through upgrading them.
Additionally it asks you to configure them and does this for all dependencies as well.

This isn't one of those set it and forget scripts you can put in crontab - you actually need to pay attention when upgrading ports and this script needs your full attention.

There a few pre-requisite things that must be addressed:
1) Make sure ports is installed or if it is installed, up to date

To Install Ports:
portsnap fetch extract

To Update Ports:
portsnap fetch update

2) Install portaudit

cd /usr/port/ports-mgmt/portaudit
make install clean

3) Install portmaster
cd /usr/ports/ports-mgmt/portmaster
make install clean

4) Create a log file /var/log/freebsd-update.log
touch /var/log/freebsd-update.log

--Script Start--
#!/bin/sh

LOG_FILE="/var/log/freebsd-update.log"

echo "Starting updates: `date`" | tee -a ${LOG_FILE}
echo "***"
echo "*** Checking for FreeBSD patches..."
echo "***"
/usr/sbin/freebsd-update fetch | tee -a ${LOG_FILE}
/usr/sbin/freebsd-update install | tee -a ${LOG_FILE}

echo "***"
echo "*** Updating ports tree..."
echo "***"
/usr/sbin/portsnap fetch update | tee -a ${LOG_FILE}

echo "***"
echo "*** Looking for ports to update..."
echo "***"
/usr/local/sbin/portmaster -a --force-config -d -b -t -v -y -t | tee -a ${LOG_FILE}

echo "***"
echo "*** Checking installed ports for known security problems..."
echo "***"
/usr/local/sbin/portaudit -Fva | tee -a ${LOG_FILE}
echo "Finished updates: `date`" | tee -a ${LOG_FILE}
--Script End--

Word of note if you need to exclude something add a -x after the -t and put in the name or partial name of a port such as:

/usr/local/sbin/portmaster -a --force-config -d -b -t -v -y -t -x LSOF | tee -a ${LOG_FILE}

You'll need to do a separate -x for each port you want to exclude.

I don't have a clue

I'm so very tired. It's almost all the time now.