Update script or GUI

PorteuX - The Next Experience. It's inspired by Slax and Porteus but with heaps of improvements
rych
Warlord
Warlord
Posts: 768
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Update script or GUI

Post#1 by rych » 10 Sep 2024, 11:26

With the welcome frequent releases of PorteuX, how would one automate the (self-)updating process with a script? It would extract the base module folder from the latest PorteuX iso of the correct channel and for the right desktop, also the new vmlinuz/initrd pair, and update the optional modules (if present) e.g. 05-devel, 08-nvidia, etc. ... and delete the old versions. The latter suggests that this script would run from a different system, in my case Porteus. I know Porteus has figured out how to update itself by scheduling the deletion of old files at the next reboot, but that's too difficult/risky to implement I guess.

If nobody has such a script yet, I'm going to have to write it myself :)

User avatar
Ed_P
Contributor
Contributor
Posts: 8911
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Update script or GUI

Post#2 by Ed_P » 10 Sep 2024, 18:02

You're welcome to tweak this old Porteus script that I use to fit your needs.

Code: Select all

#!/bin/sh
# Creates a 64-bit system bootable on UEFI & non-UEFI machines.

## https://forum.porteus.org/viewtopic.php?f=81&t=4632&p=33638#p33604
## https://forum.porteus.org/viewtopic.php?f=81&t=2700#p29085 

# Change variables to fit the situation
PORTEUS='/mnt/nvme0n1p7/porteus5.0'
#ISO='/mnt/sda6/ISOs/Porteus-CINNAMON-v4.0-x86_64.iso'
ISO='mnt/nvme0n1p7/ISOs/Porteus/Porteus-CINNAMON-v5.01-x86_64-240306.iso'
USB='/mnt/sda1'
DEV='/dev/sda1'

## Run GParted to partition & format the USB drive with a msdos Partition table.  ##
##  Use GParted's View > Device Information to check Partition Table type.        ##
##  Use GParted's Device > Create Partition Table if Partition Table shows as GPT.##
## Or under Windows use:                                                          ##
## > diskpart          * Run Command Prompt with Admin Rights.                    ##
## > list disk                                                                    ##
## >....                                                                          ##
## > select disk 1     * Note: disk nbr is the nbr of the USB disk                ##
## > clean                                                                        ##
## > create partition primary                                                     ##
## > exit                                                                         ##

function Title() {
  echo -en "\033]0;$1\a";
}
Title "Porteus USB Update"

# Color definitions
txtbld=$(tput bold)               # Bold
txtred=${txtbld}$(tput setaf 1)   # Red
txtgreen=$(tput setaf 2)${txtbld} # Green
rst=$(tput sgr0)                  # Reset
function green() {
  echo -e $txtgreen"$1" $rst; 
}
function redpswd() {
  echo -e "$1" $txtred  
}

if [ `whoami` != "root" ]; then
   echo
   green "USB=$USB" && echo
   green "PORTEUS=$PORTEUS" && echo
   green "ISO=$ISO" && echo
   read -p "Press Enter to continue, Ctrl+C to cancel" && echo 
fi

if [ `whoami` != "root" ]; then
    redpswd "Enter root's password"
    su -c "sh $0 $1"
    exit
fi
echo $rst

#cat /etc/fstab | grep "/dev/sd"

blkid $USB
if [ $? != 2 ]; then
   mount $USB
fi

#echo ls -lghtUS --color=never $USB
#ls -lghtUS --color=never $USB 
DIR () {
echo "$1"
ls -lghUS --time-style long-iso $1 | awk '{print $5,$6,$4,$7}'
# http://forum.porteus.org/viewtopic.php?f=81&t=3965#p29205
}
DIR "$USB"

echo
#set -x  # debug
read -p "This the USB drive? " && echo 
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
  exit
fi

if [ -f $USB/USB_INSTALLATION.txt ]; then
  read -p "Remove existing Porteus system files on $USB? [y/n] " && echo 
  if [[ $REPLY =~ ^[Yy]$ ]]; then
     rm -r $USB/porteus/base/*
     rm -r $USB/boot/syslinux/*
     rm -r $USB/EFI/boot/* 
     echo ls $USB/porteus/base
     ls $USB/porteus/base 
     echo
     read -p "Press Enter to continue,,. " 
   fi
fi

read -p "Write porteus ISO files to the $USB drive? [y/n] " && echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
#if [ -f $USB/USB_INSTALLATION.txt ]; then
  if [ -f /mnt/isoloop/USB_INSTALLATION.txt ]; then
    LOOP=isoloop
  else
    echo Mounting $ISO
    mloop $ISO 
    LOOP=loop
  fi
  echo "** Copying porteus ISO files to the USB drive. **" 
  echo 
  green "Please wait!! This can take a minute or two. "
  green "And if it doesn't something is wrong!!  Abort "
  echo

  mv  $USB/boot/syslinux/porteus.cfg                  $USB/boot/syslinux/porteusEd.cfg
  cp  /mnt/$LOOP/boot/syslinux/*                      $USB/boot/syslinux/
  cp  /mnt/$LOOP/EFI/boot/*                           $USB/EFI/boot/
  cp  /mnt/$LOOP/porteus/base/*                       $USB/porteus/base/
  sync
  if [ -f $USB/boot/syslinux/porteusbkup.cfg ]; then
     rm $USB/boot/syslinux/porteusbkup.cfg
     mv $USB/boot/syslinux/porteus.cfg    $USB/boot/syslinux/porteusbkup.cfg
     cp $USB/boot/syslinux/porteusEd.cfg  $USB/boot/syslinux/porteus.cfg 
  fi
  echo ls $USB/porteus/base
  ls $USB/porteus/base 
  if [ "$LOOP" = "loop" ]; then uloop; fi 
fi

echo
green "Porteus 5.0 system update complete.  Set to begin my file Restores. "
echo
read -p "Press Ctrl+C to exit & reboot, press Enter to continue..." && echo
#exit

read -p "Update /Modules, /Optional and /changes? [y/n] "
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
  echo
  green "Done"
  wait
  exit
fi 

if [ ! -f $USB/porteussave.dat ]; then
  green "Wait!! Copying $PORTEUS files to $USB/ "
  mkdir $USB/changes
  mkdir $USB/Modules
  mkdir $USB/Optional
  mkdir $USB/Guest
  cp    $PORTEUS/changes/*save.dat                $USB/changes/
  cp    $PORTEUS/Modules/*.xzm                    $USB/Modules/
#  cp    $PORTEUS/rc3Modules/07-*.xzm              $USB/Modules/
#  cp    $PORTEUS/rc3ISOModules/0*.xzm             $USB/Optional/
  cp    $PORTEUS/Optional/gtk+2.2.24*.xzm         $USB/Optional/
  cp    $PORTEUS/Optional/keepassx*.xzm           $USB/Optional/
  cp    $PORTEUS/Optional/peek*.xzm               $USB/Optional/
  cp    $PORTEUS/Optional/pysolfc-2.12.0-*.xzm    $USB/Optional/
  cp    $PORTEUS/Optional/Tightvnc*.xzm           $USB/Optional/
  cp    $PORTEUS/Optional/tree*.xzm               $USB/Optional/
  cp    $PORTEUS/Optional/xmahjongg*.xzm          $USB/Optional/
  cp    $PORTEUS/Optional/*zip*.xzm               $USB/Optional/
#  cp -r /home/guest/*                             $USB/Guest/ 
  sync
fi

echo
echo "But first, need to find the UUID and tweak lines in "
echo "the $USB/boot/syslinux/porteus.cfg file "   
echo
UUID=`blkid $DEV -o value -s UUID|cut -d\" -f 2`
echo "UUID=$UUID" 
echo  
echo "  (line 2)   TIMEOUT 300 "
echo "  (line 4)   DEFAULT safe "
echo "  (line 43)  APPEND changes=EXIT:UUID:$UUID/changes/50rc3save.dat extramod=UUID:$UUID/Modules "
echo "  (line 49)  copy lines 38-49 after it "
echo "  (line 51)  LABEL safe "
echo "  (line 52)  MENU LABEL Graphics mode (Safe) "
echo "  (line 55)  APPEND extramod=UUID:$UUID/Modules noload=save.dat "
echo "  (line 60)      allowed resolution and with "
echo "  (add  61)      NO changes saved. "
xed  $USB/boot/syslinux/porteus.cfg > /dev/null 
echo

echo "Adding Backup folders to $USB"
if [ ! -f $USB/My_Files/My_Webpages/* ]; then
  mkdir $USB/My_Files 
  USB=$USB/My_Files   
  mkdir $USB/My_Webpages    
  cp -r /mnt/nvme0n1p7/Users/Ed/"My Webpages"/*              $USB/My_Webpages/
fi
if [ ! -f $USB/My_Bkups/* ]; then
  mkdir $USB/My_Bkups
  USB=$USB/My_Bkups
  mkdir $USB/Firefox   
  cp    $PORTEUS/Guest/Backups/FireFox/book*.json            $USB/Firefox/
fi

# Windows Internet files backups
#mkdir $USB/Links
mkdir $USB/Edge
mkdir $USB/Icons
mkdir $USB/grub2
#cp /mnt/nvme0n1p7/Users/Ed/Favorites/Links/*                  $USB/Links
cp /mnt/nvme0n1p7/Users/Ed/My?Backups/Edge_Favorites/*24.html $USB/Edge
cp /mnt/nvme0n1p7/Ed/Favorites/Icons/*                        $USB/Icons
cp /mnt/nvme0n1p3/grub2/*                                     $USB/grub2
cp /mnt/nvme0n1p7/grub2/*                                     $USB/grub2/Eds
echo "Done"
sync
read
exit

robang74
Black ninja
Black ninja
Posts: 58
Joined: 20 Mar 2025, 02:16
Distribution: Ubuntu

Update script or GUI

Post#3 by robang74 » 08 Apr 2025, 07:34

rych wrote:
10 Sep 2024, 11:26
With the welcome frequent releases of PorteuX, how would one automate the (self-)updating process with a script?
This script below does not answer your question, directly:
  • Code: Select all

    https://github.com/robang74/porteus-usb-installer
but a possible approach when a major version release update is required can be:

1 keep your persistence (the original USB untouched)

2. re-creating a new LIVE system (with the same modules)

3. copy your persistence on the new storage support.

Clearly, the #2 would be much easier if a recipe of your current system would be available:
as described here.

rych
Warlord
Warlord
Posts: 768
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

Update script or GUI

Post#4 by rych » 08 Apr 2025, 11:09

I have a script now, update_porteux published here: Self-updating PorteuX
Last edited by rych on 09 Apr 2025, 09:59, edited 1 time in total.

User avatar
Ed_P
Contributor
Contributor
Posts: 8911
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Update script or GUI

Post#5 by Ed_P » 08 Apr 2025, 19:30

:good: Yup. Amazing what a 15 line script can do when you know what you're doing. :D porteux is one of the best. :)

Post Reply