Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
52 user(s) are online (39 user(s) are browsing Forums)

Members: 0
Guests: 52

more...

Support us!

Headlines

Report message:*
 

Re: Odyssey 1.23 progress

Subject: Re: Odyssey 1.23 progress
by Raziel on 2019/3/14 7:21:44

@pjs

/* WBLUpdater.rx $VER: WBLUpdater.rx 1.11 (18.12.2018) */

/* This script checks for installed versions of below mentioned files and
 updates them, if needed, automatically. It does this by checking both the
 web based and installed file dates and only if the web based file is newer
 it will be downloaded/updated.
 (If a file is not installed at all, it will simply install it without going
 through the check)

 Supported file list: curl-ca-bundle.crt, HOSTS, pci.ids

History:

 1.11: Fix:        Adapt to new HOSTS date format
 1.10: Fix:        Suppress AREXX' automatic ReadLN() processing
 1.09: Fix:        Make the log respect AmigaOS4's logfile standard
 1.08: Addition: Check for sane months to prevent downloading corrupted files
 1.07: Addition:    CALL macro used for months conversion
 1.06: Addition:    Check for the existance of and install missing files
 1.05: Fix:        Wrong format in log output
 1.04: Fix:        The hosts file was never copied
 1.03: Addition:    Add more information to the log
 1.02: Addition:    Add log file (T:) to reflect the status

*/

date_today=DATE(S)
ADDRESS COMMAND 'echo "X: [00:00:00] File name | Process | Reason | Install date | Web date" >> T:WBLUpdater.log'

/* Month conversion index */
months="Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12"



/* cURL_ca_bundle */

/* Check if file exists and install, if needed */
IF OPEN(curl_ca_bundle,'DEVS:curl-ca-bundle.crt','R') = 0 THEN DO

    
/* No file found, install it (-k insecure and -s silent) from source */
    
ADDRESS COMMAND 'curl -k -s "https://curl.haxx.se/ca/cacert.pem" -o DEVS:curl-ca-bundle.crt'
    
ADDRESS COMMAND 'copy DEVS:curl-ca-bundle.crt Tools:Internet/Netsurf/Resources/ca-bundle'
    
ADDRESS COMMAND 'copy DEVS:curl-ca-bundle.crt Tools:Internet/YAM/Resources/ca-bundle.crt'
    
ADDRESS COMMAND 'echo "W: ['TIME('N')'] curl_ca_bundle.crt | Install | Missing | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
END

ELSE DO
    
CLOSE(curl_ca_bundle)

    
/* Pulling web based file date*/
    
ADDRESS COMMAND 'curl -r84-104 -s --cacert DEVS:curl-ca-bundle.crt "https://curl.haxx.se/ca/cacert.pem" >T:cURL_ca_bundle_date'
    
OPEN(curl_ca_date,'T:curl_ca_bundle_date','R')
    
date_munged=DELWORD(READLN(curl_ca_date),3,1)
    
CLOSE(curl_ca_date)
    
ADDRESS COMMAND 'Delete T:curl_ca_bundle_date'

    
/* Converting month */
    
CALL MonthConversion
    date_web
=date_installed

    
/* Pulling installed file date */
    
OPEN(curl_ca_bundle,'DEVS:curl-ca-bundle.crt','R')
    
CALL READLN(curl_ca_bundle)
    
CALL READLN(curl_ca_bundle)
    
CALL READLN(curl_ca_bundle)
    
date_munged=DELWORD(SUBWORD(READLN(curl_ca_bundle),9,4),3,1)
    
CLOSE(curl_ca_bundle)

    
/* Converting month */
    
CALL MonthConversion

    
/* Updating file and copying it to the known places where it's used from */
    
IF date_error 0 THEN DO
        IF 
date_web date_installed THEN DO
            
ADDRESS COMMAND 'curl -s --cacert DEVS:curl-ca-bundle.crt "https://curl.haxx.se/ca/cacert.pem" -o DEVS:curl-ca-bundle.crt'
            
ADDRESS COMMAND 'copy DEVS:curl-ca-bundle.crt Tools:Internet/Netsurf/Resources/ca-bundle'
            
ADDRESS COMMAND 'copy DEVS:curl-ca-bundle.crt Tools:Internet/YAM/Resources/ca-bundle.crt'
            
ADDRESS COMMAND 'echo "I: ['TIME('N')'] curl_ca_bundle.crt | Update | Additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
        
ELSE
            
ADDRESS COMMAND 'echo "W: ['TIME('N')'] curl_ca_bundle.crt | | No additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
    
ELSE
        
ADDRESS COMMAND 'echo "E: ['TIME('N')'] curl_ca_bundle.crt | Error | Defect | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
END



/* HOSTS */

/* Check if file exists and install, if needed */
IF OPEN(hosts,'DEVS:Internet/HOSTS','R') = 0 THEN DO

    
/* No file found, install it from source */
    
ADDRESS COMMAND 'curl -s --cacert DEVS:curl-ca-bundle.crt "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts" -o DEVS:Internet/HOSTS'
    
ADDRESS COMMAND "type Tools:Internet/Network/IP-List >> DEVS:Internet/HOSTS"
    
ADDRESS COMMAND 'echo "W: ['TIME('N')'] HOSTS | Install | Missing | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
END

ELSE DO
    
CLOSE(hosts)

    
/* Pulling web based file date */
    
ADDRESS COMMAND 'curl -r127-143 -s --cacert DEVS:curl-ca-bundle.crt "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts" >T:hosts_date'
    
OPEN(hosts_date,'T:hosts_date','R')
    
date_munged=READLN(hosts_date)
    
CLOSE(hosts_date)
    
ADDRESS COMMAND 'Delete T:hosts_date'

    
/* HOSTS changed it's date format to 'day full-month 4-digit-year', thus we adapt the date to the format the other two files use ('3-letter-month day 4-digit-year') before sending it to the macro */
    
date_munged=SUBSTR(SUBWORD(date_munged,2,1),1,3SUBWORD(date_munged,1,1SUBWORD(date_munged,3,1)

    
/* Converting month */
    
CALL MonthConversion
    date_web
=date_installed
    
    
/* Pulling installed file date */
    
OPEN(hosts,'DEVS:Internet/HOSTS','R')
    
CALL READLN(hosts)
    
CALL READLN(hosts)
    
CALL READLN(hosts)
    
date_munged=SUBWORD(READLN(hosts),3,3)
    
CLOSE(hosts)

    
/* HOSTS changed it's date format to 'day full-month 4-digit-year', thus we adapt the date to the format the other two files use ('3-letter-month day 4-digit-year') before sending it to the macro */
    
date_munged=SUBSTR(SUBWORD(date_munged,2,1),1,3SUBWORD(date_munged,1,1SUBWORD(date_munged,3,1)

    
/* Converting month */
    
CALL MonthConversion

    
/* Updating file and adding the known local ip addresses */
    
IF date_error 0 THEN DO
        IF 
date_web date_installed THEN DO
            
ADDRESS COMMAND 'curl -s --cacert DEVS:curl-ca-bundle.crt "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts" -o DEVS:Internet/HOSTS'
            
ADDRESS COMMAND "type Tools:Internet/Network/IP-List >> DEVS:Internet/HOSTS"
            
ADDRESS COMMAND 'echo "I: ['TIME('N')'] HOSTS | Update | Additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
        
ELSE
            
ADDRESS COMMAND 'echo "W: ['TIME('N')'] HOSTS | | No additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
    
ELSE
        
ADDRESS COMMAND 'echo "E: ['TIME('N')'] HOSTS | Error | Defect | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
END



/* pci.ids */

/* Check if file exists and install, if needed */
IF OPEN(pci_ids,'DEVS:pci.ids','R') = 0 THEN DO
    
ADDRESS COMMAND 'curl -s --cacert DEVS:curl-ca-bundle.crt "https://pci-ids.ucw.cz/v2.2/pci.ids" -o DEVS:pci.ids'
    
ADDRESS COMMAND 'echo "W: ['TIME('N')'] pci.ids | Install | Missing | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
    
END

ELSE DO
    
CLOSE(pci_ids)
    
/* Pulling web based file date */
    
ADDRESS COMMAND 'curl -r56-65 -s --cacert DEVS:curl-ca-bundle.crt "https://pci-ids.ucw.cz/v2.2/pci.ids" >T:pci.ids_date'
    
OPEN(pci_ids_date,'T:pci.ids_date','R')
    
date_web=COMPRESS(READLN(pci_ids_date),'-')
    
/* Checking for sane months to prevent downloading corrupted files */
    
IF INDEX(months,(SUBSTR(date_web,5,2))) > 0 THEN
        date_error
=0
    
ELSE
        
date_error=1
    CLOSE
(pci_ids_date)
    
ADDRESS COMMAND 'Delete T:pci.ids_date'

    
/* Pulling installed file date */
    
OPEN(pci_ids,'DEVS:pci.ids','R')
    
CALL READLN(pci_ids)
    
CALL READLN(pci_ids)
    
CALL READLN(pci_ids)
    
CALL READLN(pci_ids)
    
date_installed=COMPRESS(SUBWORD(READLN(pci_ids),2,1),'-')
    
/* Checking for sane months to prevent downloading corrupted files */    
    
IF INDEX(months,(SUBSTR(date_installed,5,2))) > 0 THEN
        date_error
=0
    
ELSE
        
date_error=1
    CLOSE
(pci_ids)

    
/* Updating file and copying it to the known places where it's used from */
    
IF date_error 0 THEN DO
        IF 
date_web date_installed THEN DO
            
ADDRESS COMMAND 'curl -s --cacert DEVS:curl-ca-bundle.crt "https://pci-ids.ucw.cz/v2.2/pci.ids" -o DEVS:pci.ids'
            
ADDRESS COMMAND 'echo "I: ['TIME('N')'] pci.ids | Update | Additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
        
ELSE
            
ADDRESS COMMAND 'echo "W: ['TIME('N')'] pci.ids | | No additions | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
        
END
    
ELSE
        
ADDRESS COMMAND 'echo "E: ['TIME('N')'] pci.ids | Error | Defect | 'date_installed' | 'date_web'" >> T:WBLUpdater.log'
END



EXIT



MonthConversion:
date_day=SUBWORD(date_munged,2,1)
date_munged_month=SUBSTR(date_munged,1,3)
month_idx=INDEX(months,date_munged_month)
IF 
month_idx 0 THEN
    date_month
=SUBSTR(months,month_idx+3,2)

/* Checking for a sane month to prevent downloading a corrupted files */
IF INDEX(months,date_month) > 0 THEN DO
    
date_error=0
    date_year
=SUBWORD(date_munged,3,1)
    
date_installed=COMPRESS(date_year date_month date_day)
    
END
ELSE
    
date_error=1

return 0

You can rip out what you need, probably just the ca-bundle part...

Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project