scripts for keeping things in sync after upgrades?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

scripts for keeping things in sync after upgrades?

hepta tor
Hi people
When upgrading I understand it's quite important to keep things in
sync. I wanna run -current with regular upgrades and at the same time
upgrade also packages/ports (and other things if needed).
Are there any kinds of standard scripts to automate the sync? If you
already use such scripts can you share them?
thanks
-heptas

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

Peter Hessler
On 2012 Dec 04 (Tue) at 18:06:56 +0000 (+0000), Heptas Torres wrote:
:Hi people
:When upgrading I understand it's quite important to keep things in
:sync. I wanna run -current with regular upgrades and at the same time
:upgrade also packages/ports (and other things if needed).
:Are there any kinds of standard scripts to automate the sync? If you
:already use such scripts can you share them?
:thanks
:-heptas
:


sysmerge
pkg_add -u


That's it.


--
George Orwell was an optimist.

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

hepta tor
On 12/4/12, Peter Hessler <[hidden email]> wrote:

> On 2012 Dec 04 (Tue) at 18:06:56 +0000 (+0000), Heptas Torres wrote:
> :Hi people
> :When upgrading I understand it's quite important to keep things in
> :sync. I wanna run -current with regular upgrades and at the same time
> :upgrade also packages/ports (and other things if needed).
> :Are there any kinds of standard scripts to automate the sync? If you
> :already use such scripts can you share them?
> :thanks
> :-heptas
> :
>
>
> sysmerge
> pkg_add -u
>
>
> That's it.

Thanks. What I meant was more things like the script
http://gouloum.fr/code/script/install_snapshot.sh - this seems a bit
outdated and was wondering whether people use something similar for
system upgrades plus some package upgrades automatically. I was just
curious about what the best practices for automatic upgrades and syncs
are.
-h




>
> --
> George Orwell was an optimist.

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

Peter N. M. Hansteen-3
In reply to this post by Peter Hessler
Peter Hessler <[hidden email]> writes:

> sysmerge
> pkg_add -u
>
>
> That's it.

Like Peter says here, that's really all there is to it, once you know
how to run upgrades from source or via snapshot. My slightly chattier
take on doing snapshot to snapshot upgrades (yes, I'm that kind of lazy
bastid) is still reasonably fresh, datelined last July at

http://bsdly.blogspot.ca/2012/07/keeping-your-openbsd-system-in-trim.html

- P

--
Peter N. M. Hansteen, member of the first RFC 1149 implementation team
http://bsdly.blogspot.com/ http://www.bsdly.net/ http://www.nuug.no/
"Remember to set the evil bit on all malicious network traffic"
delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

Frank Brodbeck-3
In reply to this post by hepta tor
On Tue, Dec 04, 2012 at 09:44:59PM +0000, Heptas Torres wrote:
> Thanks. What I meant was more things like the script
> http://gouloum.fr/code/script/install_snapshot.sh - this seems a bit
> outdated and was wondering whether people use something similar for
> system upgrades plus some package upgrades automatically. I was just
> curious about what the best practices for automatic upgrades and syncs
> are.

This is something that I use. Though that script only fetches the
neccessary files and copies bsd.rd to /

The script saves everything in your CWD. After running the script I just
boot bsd.rd, run the upgrade and do sysmerge and pkg_add -u afterwards,
so the main benefit is keeping the downtime small and the script can
detect if the mirror you're fetching your sets from is out of sync.

Frank.

#!/bin/ksh
# $Id: snapshotset.sh,v 1.4 2012/12/04 21:49:22 fab Exp $

ARCH=$(uname -m)
MIRROR=http://openbsd.cs.fau.de/
LOCATION=pub/OpenBSD/snapshots/${ARCH}/
export showchanges=0
force=0

[[ "X$1" = 'X-f' ]] && force=1

echo "fetching SHA256 from ${MIRROR}"
ftp ${MIRROR}${LOCATION}SHA256
echo "\nfetching SHA256 from ftp.openbsd.org"
ftp -o SHA256.master http://ftp.openbsd.org/${LOCATION}SHA256

printf 'comaparing SHA256 files '
if [[ $(diff -u SHA256 SHA256.master) >/dev/null ]];
then
        print 'failed. mirror out of sync or compromised\n'
        diff -u SHA256.master SHA256
        [[ $force -eq 1 ]] || exit 2
else
        print 'ok.\n'
fi

echo "\nfetching index.txt: "
ftp ${MIRROR}${LOCATION}/index.txt
echo "\nfetching INSTALL.${ARCH}"
ftp ${MIRROR}${LOCATION}/INSTALL.${ARCH}

for i in bsd bsd.rd bsd.mp;
do
        printf "checking %s:" "$i"
        [[ -f $i && $(grep "^$(sha256 $i)$" SHA256) >/dev/null ]] && \
            echo " uptodate." || \
        {
                echo " missing or cksum mismatch, fetching."
                ftp ${MIRROR}${LOCATION}$i
                showchanges=1
        }
done

{ grep "tgz$" index.txt | awk '{ print $10 }'; }|&
while read -p basepkg
do
        printf "checking %s:" "$basepkg"
        [[ -f $basepkg && $(grep "^$(sha256 $basepkg)" SHA256) >/dev/null ]] && \
            echo " uptodate." || \
        {
                echo " missing or cksum mismatch, fetching."
                ftp ${MIRROR}${LOCATION}${basepkg}
                showchanges=1
        }
done 3>&-

printf "checking /bsd.rd:"
if [[ "$(sha256 -q bsd.rd)" = "$(sha256 -q /bsd.rd)" ]];
then
        printf " uptodate.\n"
else
        printf "Copying bsd.rd to /\n"
        su root -c "cp bsd.rd /bsd.rd"
fi

if [[ $showchanges -eq 1 ]];
then
        echo "Fetching changes from current.html"
        ftp -o - -V http://www.openbsd.org/faq/current.html | \
            egrep '<li><a href="#.*">[0-9]{4}/[0-9]{2}/[0-9]{2} - .*</a>' | \
            egrep -o '[0-9]{4}/[0-9]{2}/[0-9]{2} - [^<]+'
fi

unset showchanges

--
Frank Brodbeck <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

Oldak
Can't you use /upgrade.site[1]?

[1] http://www.openbsd.org/faq/faq4.html#site


On 4 December 2012 21:59, Frank Brodbeck <[hidden email]> wrote:

> On Tue, Dec 04, 2012 at 09:44:59PM +0000, Heptas Torres wrote:
> > Thanks. What I meant was more things like the script
> > http://gouloum.fr/code/script/install_snapshot.sh - this seems a bit
> > outdated and was wondering whether people use something similar for
> > system upgrades plus some package upgrades automatically. I was just
> > curious about what the best practices for automatic upgrades and syncs
> > are.
>
> This is something that I use. Though that script only fetches the
> neccessary files and copies bsd.rd to /
>
> The script saves everything in your CWD. After running the script I just
> boot bsd.rd, run the upgrade and do sysmerge and pkg_add -u afterwards,
> so the main benefit is keeping the downtime small and the script can
> detect if the mirror you're fetching your sets from is out of sync.
>
> Frank.
>
> #!/bin/ksh
> # $Id: snapshotset.sh,v 1.4 2012/12/04 21:49:22 fab Exp $
>
> ARCH=$(uname -m)
> MIRROR=http://openbsd.cs.fau.de/
> LOCATION=pub/OpenBSD/snapshots/${ARCH}/
> export showchanges=0
> force=0
>
> [[ "X$1" = 'X-f' ]] && force=1
>
> echo "fetching SHA256 from ${MIRROR}"
> ftp ${MIRROR}${LOCATION}SHA256
> echo "\nfetching SHA256 from ftp.openbsd.org"
> ftp -o SHA256.master http://ftp.openbsd.org/${LOCATION}SHA256
>
> printf 'comaparing SHA256 files '
> if [[ $(diff -u SHA256 SHA256.master) >/dev/null ]];
> then
>         print 'failed. mirror out of sync or compromised\n'
>         diff -u SHA256.master SHA256
>         [[ $force -eq 1 ]] || exit 2
> else
>         print 'ok.\n'
> fi
>
> echo "\nfetching index.txt: "
> ftp ${MIRROR}${LOCATION}/index.txt
> echo "\nfetching INSTALL.${ARCH}"
> ftp ${MIRROR}${LOCATION}/INSTALL.${ARCH}
>
> for i in bsd bsd.rd bsd.mp;
> do
>         printf "checking %s:" "$i"
>         [[ -f $i && $(grep "^$(sha256 $i)$" SHA256) >/dev/null ]] && \
>             echo " uptodate." || \
>         {
>                 echo " missing or cksum mismatch, fetching."
>                 ftp ${MIRROR}${LOCATION}$i
>                 showchanges=1
>         }
> done
>
> { grep "tgz$" index.txt | awk '{ print $10 }'; }|&
> while read -p basepkg
> do
>         printf "checking %s:" "$basepkg"
>         [[ -f $basepkg && $(grep "^$(sha256 $basepkg)" SHA256) >/dev/null
> ]] && \
>             echo " uptodate." || \
>         {
>                 echo " missing or cksum mismatch, fetching."
>                 ftp ${MIRROR}${LOCATION}${basepkg}
>                 showchanges=1
>         }
> done 3>&-
>
> printf "checking /bsd.rd:"
> if [[ "$(sha256 -q bsd.rd)" = "$(sha256 -q /bsd.rd)" ]];
> then
>         printf " uptodate.\n"
> else
>         printf "Copying bsd.rd to /\n"
>         su root -c "cp bsd.rd /bsd.rd"
> fi
>
> if [[ $showchanges -eq 1 ]];
> then
>         echo "Fetching changes from current.html"
>         ftp -o - -V http://www.openbsd.org/faq/current.html | \
>             egrep '<li><a href="#.*">[0-9]{4}/[0-9]{2}/[0-9]{2} - .*</a>'
> | \
>             egrep -o '[0-9]{4}/[0-9]{2}/[0-9]{2} - [^<]+'
> fi
>
> unset showchanges
>
> --
> Frank Brodbeck <[hidden email]>
>
>


--
Oldak Quill ([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: scripts for keeping things in sync after upgrades?

Paolo Aglialoro
This is what I use to re-ports, re-src comfortably....
Both good for 1st and following times
I named it "re-portssrc"

---------------------------------------------------------------------------------------
#!/bin/sh

plain=$(echo '\033[0m')
redfg=$(echo '\033[1;31m')
greenfg=$(echo '\033[1;32m')
yellowfg=$(echo '\033[01;33m')
bluefg=$(echo '\033[1;34m')
magentafg=$(echo '\033[1;35m')
cyanfg=$(echo '\033[1;36m')
whitefg=$(echo '\033[1;37m')

UTENTE=`whoami`
if [ $UTENTE = root ]; then
        echo $yellowfg"\n----> OpenBSD PORTS & SOURCES updater script 1.1
:)\n"$plain
else
        echo $redfg"\nYou gotta be root to run this script :(\n"$plain
        exit 1
fi

# Alternative automatic procedure, when dmesg gives correct version
#if [ `dmesg|grep OpenBSD|grep current` -n ] 2> /dev/null;
#        then VER=`uname -r|tr '.' '_'`
#        else VER="snapshots"
#fi

while :
do

echo
echo $yellowfg"Choose BUILD VERSION among the following:"$plain
echo
echo "s: snapshot"
echo `uname -r`": OpenBSD Stable version "`uname -r`
echo "q: quit script"
echo
echo -n 'Your choice ---> '
read CHOICE

case $CHOICE in
        s)        VER="snapshots"; break;;
        `uname -r`)    VER=`uname -r|tr '.' '_'`; break;;
        q|Q)        echo 'Bye.'; exit 2;;
        *)        echo 'Bad choice!';;
esac

done



while :
do

echo
echo $yellowfg"Choose the source server among the following:"$plain
echo
echo '1: (DE) [hidden email]:/cvs'
echo '2: (LT) [hidden email]:/cvs'
echo '3: (SI) [hidden email]:/cvs'
echo '4: (CA) [hidden email]:/cvs'
echo '5: (DE) [hidden email]:/cvs'
echo '6: (US) [hidden email]:/cvs'
echo '7: (FR) [hidden email]:/cvs'
echo '8: (AT) [hidden email]:/cvs'
echo '9: (SE) [hidden email]:/cvs'
echo 'q: quit script'
echo
echo -n 'Your choice ---> '
read CHOICE

case $CHOICE in
    1)    ANON_SRV="[hidden email]:/cvs"; break;;
    2)    ANON_SRV="[hidden email]:/cvs"; break;;
    3)    ANON_SRV="[hidden email]:/cvs"; break;;
    4)    ANON_SRV="[hidden email]:/cvs"; break;;
    5)    ANON_SRV="[hidden email]:/cvs"; break;;
    6)    ANON_SRV="[hidden email]:/cvs"; break;;
    7)    ANON_SRV="[hidden email]:/cvs"; break;;
    8)    ANON_SRV="[hidden email]:/cvs"; break;;
    9)    ANON_SRV="[hidden email]:/cvs"; break;;
    q|Q)    echo 'Bye.'; exit 2;;
    *)    echo 'Bad choice!';;
esac
done

if [ $VER = snapshots ]; then
    cd /usr; cvs -qd $ANON_SRV get -P ports; cvs -qd $ANON_SRV get -P src
else
    cd /usr; cvs -qd $ANON_SRV get -rOPENBSD_$VER -P ports; cvs -qd
$ANON_SRV get -rOPENBSD_$VER -P src
fi