Script Extracting Desktop Module Offline/Online from ISO File
Posted: 17 Feb 2017, 15:56
A script that would support extracting 003 files from downloaded iso files would be helpful.
Porteus User Forum
https://forum.porteus.org/
Code: Select all
#!/bin/bash
x3 ()
{
[[ -n $1 ]] || {
echo Usage: "<Desktop> <ISO File> [<Target Directory>]";
return
};
bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${1}.xzm;
/bin/ls $LS_OPTIONS -lh ${3:-.}/003-${1}.xzm
}
x3 $*
Code: Select all
guest@porteus:~$ x3 xfce4 p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso
-rw-r--r-- 1 guest users 46M Jun 5 2016 ./003-xfce4.xzm
guest@porteus:~$ x3 xfce4 p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso /tmp
-rw-r--r-- 1 guest users 46M Jun 5 2016 /tmp/003-xfce4.xzm
hmmmm Now if you preceeded the function with something like this:Bogomips wrote:<Desktop Extracting Script>.sh
Code: Select all
#!/bin/bash
# https://forum.porteus.org/viewtopic.php?f=140&t=6669&p=53124#p53124
ARCH=i586
if [ `echo $MACHTYPE | sed -e 's/-.*$//'` = x86_64 ]; then
ARCH=x86_64
fi
# Find closest mirror from here: http://porteus.org/porteus-mirrors.txt
MIRROR=http://www6.frugalware.org/mirrors/linux/porteus/$ARCH/Porteus-v3.2.2/
if [ `whoami` != "root" ]; then
ktsuss "$0 $1"
exit
fi
if [ -d "/tmp/*.iso" ]; then
rm /tmp/*.iso*
fi
wget $MIRROR/Porteus-$1-v3.2.2-$ARCH.iso -P /tmp
Code: Select all
echo Usage: "<Desktop> [<Target Directory>]";
Ok, where's the rest of your code?francois wrote:What about mloop iso?
My emphasis.Ed_P wrote:A script that would support extracting 003 files from downloaded iso files would be helpful.
Code: Select all
#!/bin/bash
dayset(){
# Set up Desktop Conversion Array
dtp=(cinnamon kde mate xfce);
day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
}
chkid(){
# Convert to Lower Case
id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
[[ ${day[$id]} ]] && return 0;
echo Desktop must be one of:; printf "%s\n" ${!day[*]};
return 1;
}
x3 ()
{
[[ -n $1 ]] || {
echo Usage: "<Desktop> <ISO File> [<Target Directory>]";
return
};
unset day;
declare -A day;
dayset;
chkid $1 || return $?;
bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm || return $?;
/bin/ls $LS_OPTIONS -lh ${3:-.}/003-${day[$id]}.xzm
}
x3 $*
Code: Select all
guest@porteus:~$ x3 cinn p10/tmp/iso/rc3/i586/Porteus-CINNAMON-v3.2rc3-i586.iso /tmp
Desktop must be one of:
cinnamon
mate
kde
xfce
guest@porteus:~$ x3 mate p10/tmp/iso/rc3/i586/Porteus-MATE-v3.2rc3-i586.iso /tmp
-rw-r--r-- 1 guest users 44M Jun 5 2016 /tmp/003-mate.xzm
guest@porteus:~$ x3 kde p10/tmp/iso/rc3/i586/Porteus-KDE-v3.2rc3-i586.iso /tmp
-rw-r--r-- 1 guest users 230M Jun 5 2016 /tmp/003-kde5.xzm
guest@porteus:~$ x3 cinnamon p10/tmp/iso/rc3/i586/Porteus-CINNAMON-v3.2rc3-i586.iso /tmp
-rw-r--r-- 1 guest users 65M Jun 5 2016 /tmp/003-cinnamon.xzm
guest@porteus:~$ x3 xfce p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso /tmp
-rw-r--r-- 1 guest users 46M Jun 5 2016 /tmp/003-xfce4.xzm
guest@porteus:~$ x3 kde5 p10/tmp/iso/rc3/i586/Porteus-KDE-v3.2rc3-i586.iso /tmp-rw-r--r-- 1 guest users 230M Jun 5 2016 /tmp/003-kde5.xzm
guest@porteus:~$ x3 mate p10/tmp/iso/rc3/i586/Porteus-XFCE-v3.2rc3-i586.iso
bsdtar: porteus/base/003-mate.xzm: Not found in archive
bsdtar: Error exit delayed from previous errors.
Code: Select all
iso=http://ftp.vim.org/ftp/os/Linux/distr/porteus/x86_64/Porteus-v3.2.2/modules/003-lxde.xzm
mkdir /mnt/{httpfs2,xzm}
httpfs2 $iso /mnt/httpfs2
mount /mnt/httpfs2/003-lxde.xzm /mnt/xzm
ls /mnt/xzm
Code: Select all
guest@porteus:~$ x3get cinn /tmp
Desktop must be one of:
cinnamon
mate
kde
xfce
guest@porteus:~$ x3get cinnamon /tmp
2017-02-19 18:35:59 URL:http://ftp.nluug.nl/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso [285741056/285741056] -> "/tmp/Porteus-CINNAMON-v3.2.2-i586.iso" [1]
-rw-r--r-- 1 guest users 78M Dec 24 00:19 ./003-cinnamon.xzm
Downloaded file Porteus-CINNAMON-v3.2.2-i586.iso is also accessible in /tmp
guest@porteus:~$ ls -lh /tmp/Porteus-CINNAMON-v3.2.2-i586.iso
-rw-r--r-- 1 guest users 273M Dec 24 00:59 /tmp/Porteus-CINNAMON-v3.2.2-i586.iso
Idea has already been mooted:brokenman wrote:What about mounting the file over the internet?
francois wrote:What about mloop iso?
Code: Select all
root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
using /dev/loop4
Please wait while i gather some info ....
Checking given link ...
link is good
Connecting to: Porteus-CINNAMON-v3.2.2-i586.iso ...
file name: Porteus-CINNAMON-v3.2.2-i586.iso
host name: ftp.vim.org
port number: 80
protocol: http
request path: /ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
auth data: (null)
file size: 285741056
Attemptingto mount: Porteus-CINNAMON-v3.2.2-i586.iso ...
#################################
Your online file has been mounted at:
/mnt/http
You can unmount it by typing: uloop
Here is a list of the files:
USB_INSTALLATION.txt boot porteus
root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-cinnamon.xzm
-rw-r--r-- 1 root root 78M Dec 24 00:19 /mnt/http/porteus/base/003-cinnamon.xzm
root@porteus:/home/guest# uloop
/mnt/loop has been unmounted
Code: Select all
root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso
file size: 439152640
root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-kde5.xzm
-rw-r--r-- 1 root root 225M Dec 24 00:19 /mnt/http/porteus/base/003-kde5.xzm
root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-MATE-v3.2.2-i586.iso
file size: 256028672
root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-mate.xzm
-rw-r--r-- 1 root root 50M Dec 24 00:18 /mnt/http/porteus/base/003-mate.xzm
root@porteus:/home/guest# mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-XFCE-v3.2.2-i586.iso
file size: 251113472
root@porteus:/home/guest# ls -lh /mnt/http/porteus/base/003-xfce4.xzm
-rw-r--r-- 1 root root 45M Dec 24 00:14 /mnt/http/porteus/base/003-xfce4.xzm
guest@porteus:~$ sudo mloop http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
/usr/bin/mloop: line 53: losetup: command not found
file size: 285741056
guest@porteus:~$ ls -lh /mnt/http/porteus/base/003-cinnamon.xzm
-rw-r--r-- 1 root root 78M Dec 24 00:19 /mnt/http/porteus/base/003-cinnamon.xzm
guest@porteus:~$ sudo uloop
/mnt/loop has been unmounted
That's an option!!!brokenman wrote:What about mounting the file over the internet?
Where's your x3get script?Bogomips wrote:Tried Ed's approach, which took some 5 mins, almost all of this, spent on downloading the iso:
Renamed function x3wget:Ed_P wrote:Where's your x3get script?
Code: Select all
#!/bin/bash
dayset(){
dtp=(cinnamon kde mate xfce);
day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
}
chkid(){
# Convert to Lower Case
id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
[[ ${day[$id]} ]] && return 0;
echo Desktop must be one of:; printf "%s\n" ${!day[*]};
return 1;
}
x3(){
[[ $1 ]] || { echo Usage: "<Desktop> <ISO File> [<Target Directory>]"; return; }
unset day; declare -A day;
dayset; chkid $1 || return $?;
bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm
ls -lh ${3:-.}/003-${day[$id]}.xzm
}
x3wget(){
[[ $1 ]] || { echo Usage: "<Desktop> [<Target Directory>]"; return; }
unset day; declare -A day;
dayset; chkid $1 || return $?;
# Mirror Mirror ...
fm=$(yes n | fastest-mirror 2>&1 | grep -A 2 Results: | tail -n1)
a=$(uname -m); a=${a/i6/i5}
iso=Porteus-${id^^}-v3.2.2-${a}.iso
url=${fm:6}$a/Porteus-v3.2.2/$iso
echo This will take some time . . . ; echo
wget -nv -O /tmp/$iso $url
x3 $id /tmp/$iso $2
echo Downloaded file $iso is also accessible in /tmp.
}
x3wget $*
Code: Select all
#!/bin/bash
dayset(){
dtp=(cinnamon kde mate xfce);
day[${dtp[0]}]=${dtp[0]}; day[${dtp[1]}]=${dtp[1]}5
day[${dtp[2]}]=${dtp[2]}; day[${dtp[3]}]=${dtp[3]}4
}
chkid(){
# Convert to Lower Case
id=${1,,}; id=${id/kde5/kde}; id=${id/xfce4/xfce};
[[ ${day[$id]} ]] && return 0;
echo Desktop must be one of:; printf "%s\n" ${!day[*]};
return 1;
}
x3(){
[[ $1 ]] || { echo Usage: "<Desktop> /Path/to/<ISO File> [<Target Directory>]"; return; }
unset day; declare -A day;
dayset; chkid $1 || return $?;
bsdtar xf $2 --strip-components 2 -C ${3:-.} porteus/base/003-${day[$id]}.xzm || return $?
ls -lh ${3:-.}/003-${day[$id]}.xzm
}
x3get ()
{
[[ -n $1 ]] || {
echo Usage: "<Desktop> [<Target Directory>]";
return
};
[[ $(whoami) != root ]] && {
echo Script requires Superuser Privilege, and has to be run as Root.;
return
};
[[ -n $1 ]] || return;
unset day;
declare -A day;
dayset;
chkid $1 || return $?;
fm=$(yes n | fastest-mirror 2>&1 | grep -A 2 Results: | tail -n1);
fm=${fm%/*};
# Architecture Override, when Invoked as Function,
# by setting arc=i586/x86_64 before invoking x3get.
a=${arc:-$(uname -m)}; a=${a/i6/i5}
iso=Porteus-${id^^}-v3.2.2-${a}.iso
url=http${fm#*http}/$a/Porteus-v3.2.2/$iso; # Varaiable Length fastest times
[[ -d u$$ ]] || mkdir u$$ && mountpoint -q u$$ && umount -f u$$;
echo This will take some time . . . ; echo
httpfs2 $url u$$ > /dev/null && x3 $id u$$/$iso $2;
mountpoint -q u$$ && umount u$$;
rmdir u$$
}
x3get $*
Code: Select all
guest@porteus:~$ x3get
Usage: <Desktop> [<Target Directory>]
guest@porteus:~$ x3get cinnamon /tmp
Script requires Superuser Privilege, and has to be run as Root.
root@porteus:/home/guest# x3get
Usage: <Desktop> [<Target Directory>]
Code: Select all
root@porteus:/home/guest# time x3get cinnamon /tmp
file name: Porteus-CINNAMON-v3.2.2-i586.iso
host name: ftp.vim.org
port number: 80
protocol: http
request path: /porteus/i586/Porteus-v3.2.2/Porteus-CINNAMON-v3.2.2-i586.iso
auth data: (null)
file size: 285741056
-rw-r--r-- 1 root root 78M Dec 24 00:19 /tmp/003-cinnamon.xzm
real 2m37.927s
user 0m0.239s
sys 0m1.947s
root@porteus:/home/guest# time x3get mate /tmp
file name: Porteus-MATE-v3.2.2-i586.iso
host name: ftp.vim.org
port number: 80
protocol: http
request path: /porteus/i586/Porteus-v3.2.2/Porteus-MATE-v3.2.2-i586.iso
auth data: (null)
file size: 256028672
-rw-r--r-- 1 root root 50M Dec 24 00:18 /tmp/003-mate.xzm
real 1m58.505s
user 0m0.242s
sys 0m1.307s
root@porteus:/home/guest# time x3get xfce /tmp
file name: Porteus-XFCE-v3.2.2-i586.iso
host name: ftp.vim.org
port number: 80
protocol: http
request path: /porteus/i586/Porteus-v3.2.2/Porteus-XFCE-v3.2.2-i586.iso
auth data: (null)
file size: 251113472
-rw-r--r-- 1 root root 45M Dec 24 00:14 /tmp/003-xfce4.xzm
real 1m32.261s
user 0m0.223s
sys 0m1.219s
root@porteus:/home/guest# time x3get kde /tmp
file name: Porteus-KDE-v3.2.2-i586.iso
host name: ftp.vim.org
port number: 80
protocol: http
request path: /porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso
auth data: (null)
file size: 439152640
-rw-r--r-- 1 root root 225M Dec 24 00:19 /tmp/003-kde5.xzm
real 11m10.591s
user 0m0.236s
sys 0m2.365s
And it appears it takes less disk space also since you were able to download all the DEs. Very cool Bogomips.Bogomips wrote:httpfs2 does seem to be a mite faster than the wget approach:
Code: Select all
guest@porteus:~$ time x3wget kde5 /tmp
2017-02-20 22:41:24 URL:http://ftp.vim.org/ftp/os/Linux/distr/porteus/i586/Porteus-v3.2.2/Porteus-KDE-v3.2.2-i586.iso [439152640/439152640] -> "/tmp/Porteus-KDE-v3.2.2-i586.iso" [1]
-rw-r--r-- 1 guest users 225M Dec 24 00:19 /tmp/003-kde5.xzm
Downloaded file Porteus-KDE-v3.2.2-i586.iso is also accessible in /tmp.
real 5m50.319s
user 0m2.143s
sys 0m18.500s
guest@porteus:~$ ls -lh /tmp/Porteus-KDE-v3.2.2-i586.iso
-rw-r--r-- 1 guest users 419M Dec 24 01:13 /tmp/Porteus-KDE-v3.2.2-i586.iso
Code: Select all
guest@porteus:~$ sh ./DEmod.sh mate /tmp
Script requires Superuser Privilege, and has to be run as Root.
guest@porteus:~$ sudo sh ./DEmod.sh mate /tmp
Password:
Do you think like you type?
Password:
Have you considered trying to match wits with a rutabaga?
Password:
file name: Porteus-MATE-v3.2.2-x86_64.iso
host name: ftp.nluug.nl
port number: 80
protocol: http
request path: /os/Linux/distr/porteus/x86_64/Porteus-v3.2.2/Porteus-MATE-v3.2.2-x86_64.iso
auth data: (null)
file size: 255627264
-rw-r--r-- 1 root root 49M Dec 23 23:13 /tmp/003-mate.xzm
guest@porteus:~$
Code: Select all
x3get <Desktop> [<Target Directory>]
Code: Select all
x3 <Desktop> /Path/to/<ISO File> [<Target Directory>]