Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 30 Aug 2014, 08:49
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to build a SFS downloader and installer!
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
Author Message
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Mon 27 Aug 2012, 20:10    Post subject:  How to build a SFS downloader and installer!  

I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.

Last edited by oldyeller on Wed 29 Aug 2012, 13:34; edited 3 times in total
Back to top
View user's profile Send private message 
goingnuts

Joined: 07 Dec 2008
Posts: 780

PostPosted: Tue 28 Aug 2012, 14:16    Post subject:  

Maybe not what you are asking for but here is a script to download all sfs-files from a webpage:
Code:
#!/bin/sh
wget -nd -r -A sfs http://the_target_webpage.html
#-nd = --no-directories (all files are saved in the current directory
#-r = --recursive
#-A sfs = --accept sfs
#if you would download all images instead use:
#wget -nd -r -A jpeg,jpg,bmp,gif,png http://the_target_webpage.html

For the install afterwards you could use sfs_load-1.9.6 on-the-fly or otf_sfs_loader.sh looping through the downloaded sfs-files...
Code:
for X in *.sfs; do
#some call to load sfs ex:
otf_sfs_loader.sh $X
done

NB: remember that sfs-files must be placed outside the current unionfs branch (could be in /tmp or somewhere on your save-file partition /home).

Last edited by goingnuts on Wed 29 Aug 2012, 00:31; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Tue 28 Aug 2012, 14:40    Post subject: Re: How to build a SFS downloader and installer?
Subject description: Need help
 

oldyeller wrote:
I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.


Hello, oldyeller.

You can find everything you will need for a feature like this in LazY Puppy. Just have a look at the Run-Scripts in /root/.my-sfs-scripts and/or at the Scripts for the SFS-Suites in /usr/sbin/ceelab/lazy-sfs-load

LazY Puppy tries to run a application. If the application is not available, it tries to load the sfs. If the sfs is not available, it tries to download the sfs from smokey01.com. After a successful download, LazY Puppy loads the sfs (using sfs_load) and after this the application starts (this is what the automatically generated Run-Scripts are doing). Very Happy Very Happy Very Happy

Greetings,

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Tue 28 Aug 2012, 16:30    Post subject: Re: How to build a SFS downloader and installer?
Subject description: Need help
 

RSH wrote:
oldyeller wrote:
I beleive that I can do the GUI for this just don't know the code for downloading and installing.

This is what I want to do. I would like to upload all the sfs on my ov-precise threads so that they wil all be in one place and therfore can be downloaded.

I have learned a liitle about GTKdailog but really don't know anything about bash or any of the others.


Hello, oldyeller.

You can find everything you will need for a feature like this in LazY Puppy. Just have a look at the Run-Scripts in /root/.my-sfs-scripts and/or at the Scripts for the SFS-Suites in /usr/sbin/ceelab/lazy-sfs-load

LazY Puppy tries to run a application. If the application is not available, it tries to load the sfs. If the sfs is not available, it tries to download the sfs from smokey01.com. After a successful download, LazY Puppy loads the sfs (using sfs_load) and after this the application starts (this is what the automatically generated Run-Scripts are doing). Very Happy Very Happy Very Happy

Greetings,

RSH


Thanks RSH I will take a look I really like what you did with LaYzPuppy awesome job.


goingnuts thanks but not what I was looking for.
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Wed 29 Aug 2012, 13:38    Post subject:  

This is what I am using

Quote:

#!/bin/bash

### .sfs downloader ###
### stu90 ###

### root password for user fido ###
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}


TESTSERVER="174.132.189.156"
SERVER="www.smokey01.com/Oldyeller/pet_packages-upup/"

## test server ##
ping -4 -c 1 "$TESTSERVER"
if [[ "$?" == "1" ]]; then
yaf-splash -placement center -bg yellow -fontsize large -timeout 10 -text "Either your Internet connection is not working, or the primary repository is down. Aborting SFS Downloader" &
exit 1
fi

## default download location ##
if [[ -f /etc/rc.d/PUPSTATE ]]; then
PUPPYSFS="/mnt/home/`grep 'PUPSFS' /etc/rc.d/PUPSTATE | cut -d '/' -f 2`"
fi

## action for first run with out save file ##
if [[ ! -d "$PUPPYSFS" ]]; then

## get available partitions ##
AVPART="`probepart -m | grep -v -E 'none|iso9660|swap' | cut -f 1 -d '|' | cut -f 3 -d '/' | tr '\n' '!' | sed '$s/.$//'`"

## mount partition info and gui ##
TEXT1=" This is a first boot of Puppy and you have not yet saved a session. \n You want to download the .sfs package, and this needs to be downloaded \n to the same partition in which you will be creating the session save-file.
\n Here is a list of suitable partitions. Whichever one you choose, at \n shutdown you will be asked to save the session and be sure to choose the \n same partition - please select a partition to mount from the box below: "

MNTPART=$(yad --title="$TITLE $VER" --text="$TEXT1" --form --field="mount partition:CB" "$AVPART" \
--button="gtk-quit:1" --button="gtk-ok:0")
result=$?

if [[ "$MNTPART" = "" ]]; then
echo "Exiting" && exit
fi

case $result in
0)

GETMNT=`echo $MNTPART | cut -d '|' -f 1`

## mount selected partition ##

if [[ ! -d /mnt/"$GETMNT" ]];then
mkdir -p /mnt/"$GETMNT"
mount /dev/"$GETMNT" /mnt/"$GETMNT"
fi

if [ $? -ne 0 ];then
xmessage -bg red -center "ERROR: Could not mount /dev/"$GETMNT", aborting"
exit 1
else
## set mounted partition as download location ##
PUPPYSFS="/mnt/"$GETMNT""
fi
;;
1)
echo "cancel pressed exiting"
exit
;;
esac
fi

## .sfs selection gui ##

## gui info ##
TITLE="Ov-Precise Get .sfs"
VER="0.2"
TEXT=" Please choose the .sfs packages that you would like to download from the drop down box below."

## get available .sfs on server ##
AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' '!' | sed '$s/.$//' `"

LISTSFS=$(yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --form \
--field="Available sfs":CB "$AVSFS" \
--field="Download to":DIR "$PUPPYSFS" \
--button="gtk-quit:1" --button="gtk-ok:0")

result=$?
[[ $result = 1 ]] && echo "Exiting" && exit

case $result in
0)

GETSFS=`echo $LISTSFS | cut -d '|' -f 1`
GETLOC=`echo $LISTSFS | cut -d '|' -f 2`

## move to .sfs download location ##
cd "$GETLOC"

## check if .sfs exists in download location ##
if [ -f "$GETLOC/$GETSFS" ]; then
yaf-splash -placement center -bg yellow -close never -fontsize large -timeout 10 -text "$GETSFS already exists - aborting connection" &
exit 1
else
## download .sfs - could do with some error check here ##
yaf-splash -placement center -bg yellow -close never -fontsize large -text "Please wait, downloading .sfs..." &
YPID=$!

TERMSET="urxvt -fg green -bg black -geometry 65x10+0+0 +sb -e "
$TERMSET wget -c "$SERVER/$GETSFS"


kill $YPID
fi
## load .sfs ##
if [ "$GETLOC" == "/mnt/home/$PUPPYSFS" ];then
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
else
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
fi
;;

1)
echo "cancel pressed exiting"
exit
;;
esac


would I be able to improve on this. Like not having a dropdown list but a scroll bar with the list? or is this better?
Back to top
View user's profile Send private message 
stu91


Joined: 06 Aug 2012
Posts: 145
Location: England. Dpup. Dell Inspiron 1501

PostPosted: Thu 30 Aug 2012, 07:01    Post subject:  

oldyeller wrote:


would I be able to improve on this. Like not having a dropdown list but a scroll bar with the list? or is this better?


Hi oldyeller,
I do not think it is possible to have the download to option available when using --list --column ( sroll bar ) to display available .sfs files.

For a list of different Yad options run command: yad --help-all

cheers.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Thu 30 Aug 2012, 08:22    Post subject: How to build a SFS downloader and installer!  

Hi oldyeller,
is this that what you want?
Code:
#!/bin/bash

### .sfs downloader ###
### stu90 ###
# 20120830 hacked by L18L for oldyeller
# Separate dialog "Preferences" for location where to download
# SFS files in a list with scroll bar
# version 0.2.1

### root password for user fido ###
[ "`whoami`" != "root" ] && exec sudo -A ${0} ${@}


TESTSERVER="174.132.189.156"
SERVER="www.smokey01.com/Oldyeller/pet_packages-upup/"

## test server ##
ping -4 -c 1 "$TESTSERVER"
if [[ "$?" == "1" ]]; then
yaf-splash -placement center -bg yellow -fontsize large -timeout 10 -text "Either your Internet connection is not working, or the primary repository is down. Aborting SFS Downloader" &
exit 1
fi

## default download location ##
if [[ -f /etc/rc.d/PUPSTATE ]]; then
PUPPYSFS="/mnt/home/`grep 'PUPSFS' /etc/rc.d/PUPSTATE | cut -d '/' -f 2`"
fi

## action for first run with out save file ##
if [[ ! -d "$PUPPYSFS" ]]; then

## get available partitions ##
AVPART="`probepart -m | grep -v -E 'none|iso9660|swap' | cut -f 1 -d '|' | cut -f 3 -d '/' | tr '\n' '!' | sed '$s/.$//'`"

## mount partition info and gui ##
TEXT1=" This is a first boot of Puppy and you have not yet saved a session. \n You want to download the .sfs package, and this needs to be downloaded \n to the same partition in which you will be creating the session save-file.
\n Here is a list of suitable partitions. Whichever one you choose, at \n shutdown you will be asked to save the session and be sure to choose the \n same partition - please select a partition to mount from the box below: "

MNTPART=$(yad --title="$TITLE $VER" --text="$TEXT1" --form --field="mount partition:CB" "$AVPART" \
--button="gtk-quit:1" --button="gtk-ok:0")
result=$?

if [[ "$MNTPART" = "" ]]; then
echo "Exiting" && exit
fi

case $result in
0)

GETMNT=`echo $MNTPART | cut -d '|' -f 1`

## mount selected partition ##

if [[ ! -d /mnt/"$GETMNT" ]];then
mkdir -p /mnt/"$GETMNT"
mount /dev/"$GETMNT" /mnt/"$GETMNT"
fi

if [ $? -ne 0 ];then
xmessage -bg red -center "ERROR: Could not mount /dev/"$GETMNT", aborting"
exit 1
else
## set mounted partition as download location ##
PUPPYSFS="/mnt/"$GETMNT""
fi
;;
1)
echo "cancel pressed exiting"
exit
;;
esac
fi

## .sfs selection gui ##

## gui info ##
TITLE="Ov-Precise Get .sfs"
VER="0.2.1"

function getloc() {
        GETLOC=$(echo "$AVSFS" | sed -r s%!%\n%  | \
                 yad --title="$TITLE $VER Preferences" --width="300" --justify=center  \
                     --form --field="Download to":DIR "$PUPPYSFS" \
                 )
         result=$?
         case $result in
         1|252) exit ;;
             0) GETLOC=${GETLOC%%|*}  # cut -d '|' -f1       
         esac
}

while true; do # endless loop

[ "$GETLOC" ] || getloc # if $GETLOC is not set then set it

##move "Download to" Preferences
#GETLOC=$(echo "$AVSFS" | sed -r s%!%\n%  | \
#         yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" \
#             --form --field="Download to":DIR "$PUPPYSFS" \
#         )
#result=$?
#GETLOC=${GETLOC%%|*}         
#echo result=$result
#case $result in
# 1|252) exit;;
#     0) GETLOC=${GETLOC%%|*}  # cut -d '|' -f1       
#esac

#TEXT=" Please choose the .sfs packages that you would like to download from the drop down box below."

## get available .sfs on server ##
#AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' '!' | sed '$s/.$//' `"

#LISTSFS=$(yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --form \
#--field="Available sfs":CB "$AVSFS" \
#--field="Download to":DIR "$PUPPYSFS" \
#--button="gtk-quit:1" --button="gtk-ok:0")

TEXT=" Please choose the .sfs packages that you would like to download from the list below.
 Download to ${GETLOC} (Can be changed in Preferences) "
AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `"
LISTSFS=$(echo "$AVSFS" | sed -r s%!%\n%  | \
          yad --title="$TITLE $VER" --text --justify=center --text="$TEXT" --height="220" \
              --list --column="Available sfs":2   \
              --button="gtk-preferences":3 \
              --button="gtk-quit:1" --button="gtk-ok:0")
result=$?
case $result in
 1|252) echo "Exiting" && exit ;;
     3) getloc ;;
     0)

GETSFS=`echo $LISTSFS | cut -d '|' -f 1`

## move to .sfs download location ##
cd "$GETLOC"

## check if .sfs exists in download location ##
if [ -f "$GETLOC/$GETSFS" ]; then
yaf-splash -placement center -bg yellow -close never -fontsize large -timeout 10 -text "$GETSFS already exists - aborting connection" &
exit 1
else
## download .sfs - could do with some error check here ##
yaf-splash -placement center -bg yellow -close never -fontsize large -text "Please wait, downloading .sfs..." &
YPID=$!

TERMSET="urxvt -fg green -bg black -geometry 65x10+0+0 +sb -e "
$TERMSET wget -c "$SERVER/$GETSFS"


kill $YPID
fi
## load .sfs ##
if [ "$GETLOC" == "/mnt/home/$PUPPYSFS" ];then
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
else
yaf-splash -placement center -bg green -fontsize large -timeout 10 -text "$SFSGET download complete - load .sfs now..." &
sfs_load "${GETSFS}" &
echo "exit" && exit 0
fi
;;

esac

done
sfsget-0.2.1.png
 Description   
 Filesize   28.35 KB
 Viewed   563 Time(s)

sfsget-0.2.1.png


Last edited by L18L on Thu 30 Aug 2012, 13:02; edited 1 time in total
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Thu 30 Aug 2012, 12:22    Post subject:  

Hi L18L,

That will workout just fine. This will be nice once I have Manna-002 out.

Cheers.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Thu 30 Aug 2012, 13:07    Post subject:  

Glad to see it is useful and you like it Very Happy
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Thu 30 Aug 2012, 14:52    Post subject:  

L18L wrote:
Glad to see it is useful and you like it Very Happy


There is just one thing that I did notice when looking at both of these.

Not sure why this is like this any ideas?

I did look at the sfs file and the extension is sfs
sfsget 0.2.1.jpg
 Description   This is yours notice the .sf
 Filesize   86.92 KB
 Viewed   535 Time(s)

sfsget 0.2.1.jpg

getsfs 0.2.jpg
 Description   The sfs is ok with this one
 Filesize   68.59 KB
 Viewed   339 Time(s)

getsfs 0.2.jpg

Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Fri 31 Aug 2012, 05:04    Post subject: missing s at the end of list
Subject description: simple work around
 

Thanks for the bug report
oldyeller wrote:
Not sure why this is like this any ideas?

No idea why this happens
but a simple workaround is: just append a s to the list of available sfs (AVSFS)

# 20120831 appending missing s to AVSFS
# version 0.2.2

#AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `" # 20120831
AVSFS="` curl -s $SERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | sed '$s/.$//' `s" # 20120831
sfsget-0.2.2.png
 Description   bug fix
 Filesize   12.49 KB
 Viewed   508 Time(s)

sfsget-0.2.2.png

Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Fri 31 Aug 2012, 11:31    Post subject:  

L18L
thanks for your help on this that worked out just fine.
I added a note for the fix.

I some point I will learn how to do code myself Very Happy Very Happy


Cheers
Back to top
View user's profile Send private message 
RSH


Joined: 05 Sep 2011
Posts: 2420
Location: Germany

PostPosted: Fri 31 Aug 2012, 19:00    Post subject:  

Hi.

Again a useful script by stu90. Cool

Again i "found" it from a post of oldyeller. Surprised

Again i could not resist to make a useful and comfortable tool by this inspiration. Laughing

Again i did learn something. Cool Very Happy

What i did use from the script (i do not know such commands and do wish, i would have the bash knowledge of stu90), is:

(already modified for sfs)

Code:
AVSFS="` curl -s $NEWSERVER | awk -F '\"' '/href=\".*\.sfs/ {print $8}' | sort -f -u | tr '\n' ' ' | sed '$s/.$//' `"


and (modified for .pet)

Code:
AVPET="` curl -s $NEWSERVER | awk -F '\"' '/href=\".*\.pet/ {print $8}' | sort -f -u | tr '\n' ' ' | sed '$s/.$//' `"


The result is: ---> Cool Cool Cool LazY FReD 0.1! Cool Cool Cool



RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Fri 31 Aug 2012, 20:14    Post subject:  

Very nice

I will take a look and check it out. Very Happy Very Happy
Back to top
View user's profile Send private message 
oldyeller


Joined: 15 Nov 2011
Posts: 779
Location: Mishawaka IN

PostPosted: Sat 01 Sep 2012, 12:07    Post subject:  

stu91 or L18L,

How do I put an icon on the bar?
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1191s ][ Queries: 13 (0.0047s) ][ GZIP on ]