scripts

Script or scripting may refer to: read more at WikiPedia

  • oracle_logo3

    The Oracle WebLogic 11g application server product line is the industry's most comprehensive Java platform for developing, deploying, and integrating enterprise applications. It provides the foundation for application grid, which is an architecture that enables enterprises to outperform their competitors while minimizing operational costs.

    Some notes

    This script may look unsecure (and it is)

    Since password are store inside (admin server login: admin and password is admin), by doing so I can restart Oracle Weblogic in a cron job since stopping wont query the console for the login and password: feel free to remove these lines in blue

    I always recommend to install web process in its own user group and use a dedicated user to mitigate any securities issues:

    # groupadd weblogic
    # useradd -g weblogic-c weblogicuser for weblogic' -m weblogic
    # su – weblogic

    Install then weblogic in /home/weblogic

    Respect the order of component for starting

    1. Start Weblogic Node Manager,
    2. Start WebLogic Admin server,
    3. Start all Managed Server in any order.

    and stopping components

    1. Stop the Node Manager
    2. Stop all Managed WebLogic server
    3. Stop WebLogic

    Names of the managed server

     managed server names are in the script so add remove start and stop command for them

    Logs files of start and stop operations

    are written in 2 files, that use timestamp, see WLS_LOG_START and WLS_LOG_STOP

    /etc/init.d/weblogic file

    Create a new file as root in /etc/init.d/weblogic

    # vi /etc/init.d/weblogic

    and paste inside the following

    #!/bin/sh
    # description: webLogic adminServer and managedServer start script
    #

    # customized below to your likings
    WLS_DOMAIN=mytestdomain
    WLS_BASE=/home/weblogic/
    WLS_HOME=${WLS_BASE}/bea/user_projects/domains/$WLS_DOMAIN
    WLS_NODE_HOME=${WLS_BASE}/bea/wlserver_10.3/server/bin
    WLS_OWNER=
    weblogic
    WLS_ADMIN_PORT=7001
    WLS_ADMIN_LOGIN=admin
    WLS_ADMIN_PWD=admin
    WLS_LOG_START=${WLS_BASE}/logs/start.`date '+%d%m%y'`.log
    WLS_LOG_STOP=${WLS_BASE}/logs/stop.`date '+%d%m%y'`.log
    WLS_MANAGED_SERVER1=dev
    WLS_MANAGED_SERVER2=test
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.management.username=${WLS_ADMIN_LOGIN}"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.management.password=${WLS_ADMIN_PWD}"

    export JAVA_OPTIONS

    if [ ! -f $WLS_HOME/startWebLogic.sh ]
    then
        echo "WebLogic startup: cannot $WLS_HOME/startWebLogic.sh "
        exit
    fi

    startWeblogic()
    {
    su - $WLS_OWNER -c "nohup $WLS_NODE_HOME/startNodeManager.sh > ${WLS_LOG_START} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/startWebLogic.sh >> ${WLS_LOG_START} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/bin/startManagedServer.sh >> ${WLS_LOG_START} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/bin/startManagedServer.sh >> ${WLS_LOG_START} 2>&1 &"
    return 0
    }

    stopWeblogic()
    {
    su - $WLS_OWNER -c "nohup $WLS_NODE_HOME/stopNodeManager.sh > ${WLS_LOG_STOP} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/bin/stopManagedWebLogic.sh $WLS_MANAGED_SERVER1t3://localhost:$WLS_ADMIN_PORT ${WLS_ADMIN_LOGIN} ${WLS_ADMIN_PWD} >> ${WLS_LOG_STOP} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/bin/stopManagedWebLogic.sh $WLS_MANAGED_SERVER2 t3://localhost:$WLS_ADMIN_PORT  ${WLS_ADMIN_LOGIN} ${WLS_ADMIN_PWD}>> ${WLS_LOG_STOP} 2>&1 &"
    sleep 10
    su - $WLS_OWNER -c "nohup $WLS_HOME/bin/stopWebLogic.sh >> ${WLS_LOG_STOP} 2>&1 &"
    return 0
    }

    case "$1" in
        'start')
            startWeblogic
            ;;
        'stop')
            stopWeblogic
            ;;
        'restart')
            stopWeblogic
            startWeblogic
            ;;
        *)
            echo "Usage: $0 start|stop|restart"
            exit 1
            ;;
    esac



  • joomla_logo

    These are the script I use to maintains all my 3 demo Joomla! sites:

    These scripts increased security and are trying to standardized how to create, update and maintain Joomla! demo site. Feel free to submit, send me ideas how to improve them or ask for help.

     

    This project is hosted at http://forge.joomla.org/gf/project/demosite/ under a GPL v3.0 license and the latest documentation can be found in my WIKI

    Architecture

    • 1 script (snapshotit.bat ) per Joomla! instance to create snapshots (files+ database) and save the result in a zip file.
    • 1 generic scripts (renew.sh) that renew an instance of Joomla! (files+ database) and secure it at the same time

    Prerequisites

    1. An access to a Linux bash on your server, ideally as root
    2. The possibility to define new crontab entries

    Locally

    On your desktop or reference server, install preferably in xampp/htdocs as much version of Joomla! as needed. These directories are containing Joomla versions . In these versions you will be able to install, remove configure your extensions. I personally have them  in XAMPP

    demo-joomla-1.0/
    demo-joomla-1.5/
    demo-joomla-1.6/

    In each of these Joomla! installation, copy this file snapshotit.bat inside and configure the variables accordingly. The file is well documented to not describe these variables here.

    This small batch file is making a snapshot of all files and database and create a new file demo-joomla-1.5.zip for example.

    Consider while installing Joomla!

    1. To not choose as a default for table name the prefix jos_ but something longer and more random, something like gZ45dF_ to mitigate SQL injection
    2. Do not name your admin user admin, but choose something longer and more random, Fdhtz56df_Gdte34 to reduce risk of brute forcing the administrator login/sql injection

    On the server

    Copy now this file demo-joomla-1.5.zip to your server, using FTP, SSH

    Copy also renew.sh to your server, using FTP, SSH

    Setup crontab

    Add to your crontab for each of your demo site the following big line, I renew demo site every 30 minutes

    $ crontab -e

    add this line

    30      *       *       *       *       locationOf_renew.sh locationOf_zip locationof_httpdocs dbuser dbpassword dbtablename unixuser unixgrp

    where

    • locationOf_renew.sh fully qualified path to renew.sh
    • locationOf_zip  fully qualified path of zip file (containing Joomla! and .sql file)
    • locationof_httpdocs fully qualified path of the httpdocs directory where this zip file content will be extracted
    • dbuser : database user that is used by Joomla!
    • dbpassword : database user password that is used by Joomla!
    • dbtablename: database schema name that is used by Joomla!
    • unixuser: unix user that is supposed to own all files in httpdocs, for example cedric
    • unixgrp: unix user that is supposed to own all files in httpdocs, for example psaserv

    Renew.sh

    This script renew.sh is doing the following with the zip file

    1. Delete all files in locationof_httpdocs removing all potential security threat and settings changes by visitors of your demo site
    2. Lock the demo site by adding an htaccess and htpasswd files temporary
    3. Unzip all file in demo-joomla-1.5.zip  to locationof_httpdocs
    4. Restore the database with the file demo-joomla-1.5.sqlfound in demo-joomla-1.5.zip
    5. Change user and usergrp to the right one (unixuser, unixgrp)
    6. Change all files and directory to the minimum required set of permissions (555 for directory and 444 for files)
    7. Make the cache directory of Joomla! read write for the owner unixuser
    8. Delete the file  demo-joomla-1.5.sql
    9. It remove potentially dangerous components from demo site, among others
      1. com_media Removing the users the right to upload, alter or delete files
      2. com_config Removing the users the right to change configuration
      3. com_installer Removing the users the right to install extensions
      4. it remove installation or installation.old if present
    10. Unlock the demo site by removing the htaccess and htpasswd files, and restoring the one from the zip files

    All in all and thanks to this development, my 3 demo site are now online, update will be a lot easier and I will keep them more often up to date Smile

    Joomla! 1.0 tricks

    In Joomla! 1.0 configuration.php I use the following trick to not have any stage dependent values.

    $mosConfig_absolute_path = dirname(__FILE__);
    $mosConfig_cachepath = dirname(__FILE__).'/cache';
  • xenserver_logo_lg

    More and more I am using XEN at work, and here is a small how to of some very common operations.

    Citrix® XenServer® is a complete, managed server virtualization platform built on the powerful Xen® hypervisor. Xen technology is widely acknowledged as the fastest and most secure virtualization software in the industry. XenServer is designed for efficient management of Windows® and Linux® virtual serversand delivers cost-effective server consolidation and business continuity.

    By the way if you succeed installing XEN server on a Strato.com dedicated Linux server with a minimal downtime, contact me I am interested!

    Basic operations

    Determine the XEN guest uuid

    This uuid is required to identify XEN guest.

    # xe vm-list
    uuid ( RO)           : 99bb0e42-0616-6f02-ed41-be48bb338280 
         name-label ( RW): server01
        power-state ( RO): running

    Determine the XEN sr-uuid of a disk storage

    A sr-uuid identify a storage resources attached to a XEN server, this unique id is required for some operations as it allow you for eample to import XEN guest into it.

    Run as root, in the XEN server console


    # xe sr-list
    uuid ( RO)                : 99f191c4-4563-8672-7d8e-4602850fbeb0
            name-label ( RW): Local storage
            name-description ( RW): 
            host ( RO): xen01
            type ( RO): lvm
            content-type ( RO): user

    Identify the locale storage by looking at the name-label and copy the uuid

    Export XEN Guest

    1. You need to stop the XEN guest prior to any operations
    2. You need to determine the XEN guest uuid (see basic operations)
    3. Mount a NFS / CIFS / Samba share if you want to move from one XEN server to another as the filename can be located anywhere.

    Run as root, in the XEN server console

    # xe vm-export vm=99bb0e42-0616-6f02-ed41-be48bb338280  filename=server01.xva

    Import XEN Guest

    1. You need to determine the XEN guest sr-uuid (see basic operations) : the storage unique id
    2. Mount a NFS / CIFS / Samba share if you want to move from one XEN server to another as the filename can be located anywhere.

    Run as root, in the XEN server console

    # xe vm-import filename=server01.xva  sr-uuid=99bb0e42-0616-6f02-ed41-be48bb338280 

    Export a XEN template to disk

    1. Log to the XEN server where this template is located, and list all templates
    2. Mount a NFS / CIFS / Samba share if you want to move from one XEN server to another as the filename can be located anywhere.

    # xe template-list

    If there is too much templates, you can filter with grep or by using name-label

    # xe template-list  name-label="myTemplate label”
    uuid ( RO) : c4962b6b-5678-a72b-85cd-e33f01b1320a
    name-label ( RW): mytemplate label
    name-description ( RW):

    To export, run

    # xe template-export uuid=c4962b6b-5678-a72b-85cd-e33f01b1320afilename=myTemplate.xva

    You can see the export progression in tab “logs“ of that template in XEN-Center

    Import a XEN template to a new XEN Server

    1. Log to the XEN server where you want to import the new template
    2. You need to determine the XEN guest sr-uuid (see basic operations) : the storage unique id

    To import, run

    # xe vm-import filename=myTemplate.xva  sr-uuid=99bb0e42-0616-6f02-ed41-be48bb338280 

    TO be continued…

  • Call task1, if the variable contains 'true', 'on', or '1' the task 'send a sms alert' is executed
    
    
    
    
    
    
  • A properties file in c:/confA commentstmp.path=c:\tempftp.login.default=cedricwalterftp.pwd.default=xxxxftp.host=ftp.adress.comftp.port=21
    
    
    
    
    
    
  • This script ask for security reason the login and password. (but accept default values)
    
    
     
    
    
    
     
    
    
    
    
    
    
  • This script ask for security reason the login and password. (but accept default values)