Automatic update
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Papiosaur
    Posts: 1578 from 2003/4/10
    From: France
    Hello all,

    i would like to create a script in AmigaDOS to compare two variables containing version number of a software (eg Wayfarer)

    one variable is in the file:
    https://www.morphos-storage/network/web/wayserver.version (for now the variable is 38 for 3.8)

    the other variable is in local:
    sys:prefs/env-archives/waylocal.version (for now the variable is 37 for 3.7)

    my script will be :

    if wayserver.version > waylocal.version
    execute https://www.morphos-storage/network/web/wayfarer.install
    endif

    Thanks for your help :-D

    [ Edité par Papiosaur 06.06.2022 - 21:08 ]

    [ Edité par Papiosaur 07.06.2022 - 10:00 ]
  • »06.06.22 - 20:08
    Profile Visit Website
  • MorphOS Developer
    Piru
    Posts: 524 from 2003/2/24
    From: finland, the l...
    @papiosaur

    I would avoid using integer value derived like that: The problem is that 310 (3.10) would then be considered newer than 40 (4.0). This is bad.

    You should rather use version command that can compare both version and revision individually.

    Code:

    set VER=3
    set REV=8
    version >NIL: path/to/wayfarer version $VER revision $REV
    if warn
    echo "Wayfarer is older than $VER.$REV"
    else
    echo "Wayfarer is version $VER.$REV or newer"
    endif
  • »06.06.22 - 22:29
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Papiosaur
    Posts: 1578 from 2003/4/10
    From: France
    Normally, if you put this script in wbstartup with an icon with script option, Wayfarer will be automaticaly updated to 3.8 (with requester of course).

    Code:

    cd ram:
    set VER=3
    set REV=8
    version >NIL: sys:Applications/Wayfarer/Wayfarer version $VER revision $REV
    if warn
    wget --no-check-certificate https://www.morphos-storage.net/network/web/wayfarer.install
    execute wayfarer.install
    else
    echo "You have the last version of Wayfarer installed"
    ENDIF


    Now i must increase REV to 9 for the next version.
    I think this script will be on the server and will be downloaded and executed at startup.

    Thanks Piru!!!

    [ Edité par Papiosaur 07.06.2022 - 13:50 ]
  • »07.06.22 - 06:20
    Profile Visit Website
  • jPV
  • Paladin of the Pegasos
    Paladin of the Pegasos
    jPV
    Posts: 1884 from 2003/2/24
    From: po-RNO
    There's the handy Newer command in MorphOS. It compares version strings found in two files, so if you have a file containing a version string ("$VER: Wayfarer 3.8", for example), you can compare that against the actual executable file.

    You could have a separate version file like "https://www.morphos-storage/network/web/wayserver.version", but why not add a version string into "https://www.morphos-storage/network/web/wayfarer.install" and you could go with one download for both version checking and installing.

    Here's example(s):
    Code:
    ; Set files here, no need to modify rest of the code then:
    Set LOCALFILE "SYS:Applications/Wayfarer/Wayfarer"
    Set REMOTEURL "https://jpv.amigaaa.com/"
    Set REMOTEFILE "wayserver.version"

    ; Examples for testing newer and older version strings:
    ;Set REMOTEFILE "wayserver.version_old"
    ;Set REMOTEFILE "wayserver.version_new"

    ; If the wayfarer.install file would include a version string (no need for a separate version file):
    ;Set REMOTEURL "https://www.morphos-storage.net/network/web/"
    ;Set REMOTEFILE "wayfarer.install"



    ; The actual script:

    FailAt 21 ; Don't stop execution on fails, but handle them in the script.

    wget -q --no-check-certificate -O "RAM:$REMOTEFILE" $REMOTEURL$REMOTEFILE

    Newer "$LOCALFILE" "RAM:$REMOTEFILE"
    Set NEWRC $RC

    If $NEWRC EQ 5
    Echo "Remote is newer!"
    Else
    If $NEWRC GE 10
    Echo "Can't check the version!"
    Else
    Echo "Remote is not newer."
    EndIf
    EndIf

    Unset NEWRC
    Unset REMOTEFILE
    Unset REMOTEURL
    Unset LOCALFILE
  • »07.06.22 - 11:06
    Profile Visit Website
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Papiosaur
    Posts: 1578 from 2003/4/10
    From: France
    Maybe more complicated to understand for me but i will try to understand it and use it ;-)

    Thanks a lot jPV too!!!


    [ Edité par Papiosaur 07.06.2022 - 13:59 ]
  • »07.06.22 - 12:58
    Profile Visit Website
  • MorphOS Developer
    Piru
    Posts: 524 from 2003/2/24
    From: finland, the l...
    Generally --no-check-certificate option should not be used, ever. Verifying certificates is a critical part of the security of the modern web.

    If for some reason wget cannot find the CA bundle (maybe it has been compiled with some weird options) you can specify the path with --ca-certificate option. MorphOS provides the CA bundle in MOSSYS:Data/SSL/curl-ca-bundle.crt
  • »07.06.22 - 20:51
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Papiosaur
    Posts: 1578 from 2003/4/10
    From: France
    Thanks Piru, i must put this line ?

    wget --ca-certificate MOSSYS:Data/SSL/curl-ca-bundle.crt https://www.morphos-storage.net/network/web/wayfarer_3.9.lha
  • »29.06.22 - 07:47
    Profile Visit Website