Ignore:
Timestamp:
Sep 6, 2001, 5:22:47 AM (24 years ago)
Author:
bird
Message:

Upload database to netlabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/DailyBuild/odin32db.cmd

    r6126 r6668  
    1 /* $Id: odin32db.cmd,v 1.3 2001-06-27 08:55:14 bird Exp $
     1/* $Id: odin32db.cmd,v 1.4 2001-09-06 03:22:47 bird Exp $
    22 *
    33 * Updates the Odin32 API database.
     
    1717    parse source sd1 sd2 sScript
    1818    sScriptDir = filespec('drive', sScript) || filespec('path', sScript);
    19 
    2019    'cd tools\database';
    2120    if rc <> 0 then call failure rc, 'cd db failed';
     
    4039    'd:';
    4140    'cd ..';
     41
     42    /* dump database and install the dump at netlabs */
     43    'mkdir db'
     44    'mysqldump --no-create-db --add-drop-table --allow-keywords -Tdb odin32'
     45    if (rc <> 0) then call failure rc, 'mysqldump failed';
     46    '@rm -f odin32db.dump'
     47    'mysqldump --no-create-db --add-drop-table --allow-keywords -e odin32 > odin32db.dump'
     48    if (rc <> 0) then call failure rc, 'mysqldump (2) failed';
     49    'zip -9 odin32db.zip odin32db.dump'
     50    if (rc <> 0) then call failure rc, 'createing odin32db.zip failed';
     51    rc = SysFileTree('db\*', 'asFiles', 'O');
     52    if (rc <> 0) then call failure rc, 'listing db\* failed';
     53    do i = 1 to asFiles.0
     54        rc = putRexxFtp(asFiles.i, '/dev/12345678', '/daily/db', 'ftp.netlabs.org');
     55        if (rc <> 0) then call failure rc, 'uploading of 'asFiles.i' failed';
     56    end
     57    rc = putRexxFtp('odin32db.zip', '/dev/12345678', '/daily/db', 'ftp.netlabs.org');
     58    if (rc <> 0) then call failure rc, 'uploading of 'asFiles.i' failed';
     59
     60    sPwdDummy = GetPassword('odin32dbupdate');
     61    parse var sPwdDummy sPasswd':'sDummy
     62    'wget -O /dev/con http://www.netlabs.org/odin/odin32dbtest/Odin32DBUpdate.phtml?sPasswd='||sPasswd
     63    if (rc <> 0) then call failure rc, 'wget failed';
     64
     65
    4266    exit(0);
    4367
     
    4670    say 'rc='rc sText
    4771    exit(rc);
     72
     73failure2: procedure
     74parse arg rc, sText;
     75    say 'rc='rc sText
     76    return 0;
    4877
    4978
     
    79108    return sDataDir;
    80109
     110/*
     111 *
     112 *  From odin32ftp2.cmd
     113 *  From odin32ftp2.cmd
     114 *  From odin32ftp2.cmd
     115 *  From odin32ftp2.cmd
     116 *  From odin32ftp2.cmd
     117 *  From odin32ftp2.cmd
     118 *
     119 */
     120
     121
     122/*
     123 * Reads the password file (passwd) in the script directory to
     124 *   get a password and userid for a given site.
     125 *
     126 * Format of the passwd file is:
     127 *  <site> <user> <password>
     128 * Lines starting with '#' is ignored.
     129 *
     130 * @param   sSite   name of the site.
     131 * @returns String on the form '<userid>:<passwd>' if found.
     132 *          Empty string if not found.
     133 */
     134GetPassword: procedure;
     135    parse upper arg sSiteToFind
     136    parse source sd1 sd2 sScript
     137    sPasswd = filespec('drive', sScript) || filespec('path', sScript)||'\passwd';
     138
     139    rc = stream(sPasswd, 'c', 'open read');
     140    if (pos('READY', rc) <> 1) then
     141    do
     142        say 'failed to open ftp password file - rc='rc;
     143        return '';
     144    end
     145
     146    sRet = '';
     147    do while (lines(sPasswd) > 0)
     148        sLine = strip(linein(sPasswd));
     149        if (sLine = '' | substr(sLine, 1, 1) = '#') then
     150            iterate;
     151
     152        parse var sLine sSite' 'sUser' 'sPassword' 'sDummy
     153        sSite = translate(strip(sSite));
     154        sUser = strip(sUser);
     155        sPassword = strip(sPassword);
     156        if (sSite = '' | sPassword = '' | sUser = '') then
     157            say 'warning! misformed password line!';
     158        if (sSite = sSiteToFind) then
     159        do
     160           sRet = sUser||':'||sPassword;
     161           leave
     162        end
     163    end
     164    call stream sPasswd, 'c', 'close';
     165    return sRet;
     166
     167
     168/*
     169 * REXX FTP put function.
     170 */
     171putRexxFtp: procedure
     172    parse arg sFile, sLockFile, sRemoteDir, sSite
     173
     174    /* check for done-lock */
     175    if stream(sLockFile,'c','query exists') = '' then
     176    do
     177        say '--- put' sFile '->' sRemoteDir'/'sFile '---';
     178
     179        /* get password */
     180        sPasswdString = GetPassword(sSite);
     181        if (sPasswdString = '') then
     182        do
     183            call failure rc, 'Can''t find userid/password for' sSite'.', -1;
     184            return -1;
     185        end
     186        parse var sPasswdString sUser':'sPasswd;
     187
     188        /* log on the ftp site */
     189        rc = FtpSetUser(sSite, sUser, sPasswd);
     190        if (rc = 1) then
     191        do
     192            /* put file, delete it if we fail */
     193            say sSite  sUser  sPasswd  sFile  sRemoteDir'/'filespec('name', sFile)  'Binary'
     194            rcPut = FtpPut(sFile, sRemoteDir'/'filespec('name',sFile), 'Binary');
     195            /*
     196            if (rcPut <> 0) then
     197                rc = FtpDelete(sRemoteDir'/'filespec('name', sFile));
     198            */
     199
     200            /* Logoff and make lock file. */
     201            rc = FtpLogoff();
     202            if (rcPut = 0) then
     203                'echo ok  ' || sLockFile; /* changed - no lockfile */
     204            else
     205                call failure2 rc, 'FtpPut failed -' sSite , FTPERRNO;
     206            rc = rcPut;
     207        end
     208        else
     209        do
     210            call failure2 rc, 'Logon failed -' sSite, FTPERRNO;
     211            if rc = 0 then rc = -1;
     212        end
     213    end
     214    else
     215        rc = 0;
     216    return 0;
     217
     218
Note: See TracChangeset for help on using the changeset viewer.