Sign up to create your own snipts, or login.

Public snipts » server The latest public server snipts.

showing 1-20 of 83 snipts for server
  • convert cPanel accounts after activating suPHP
    #!/bin/bash
    
    # Script must be run by a user with access to all accounts, their files and folders
    
    # Known limitation:
    # - handles only sites located in /account/public_html/, so it won't work for
    #   websites in /account/public_html_other/ or /account/public_html/other/
    
    # the root is the folder that contains all your account folders
    # default is pwd (Parent Working Directory)
    rootDir=`pwd`
    
    # accounts' webroot foldername
    webRoot="public_html"
    
    # loop through folders in current folder
    for i in $(find . -type d -maxdepth 1 -mindepth 1); do
        echo .................
        accountName=${i:2}
        echo Account: ${accountName}
    
        # check if folder has a webroot subfolder
        if [ -d $rootDir/$accountName/$webRoot ]; then
            cd $rootDir/$accountName/$webRoot
    
            # change owner for all files and folders in webroot
            chown -R $accountName:nobody *
    
            # change access for all files in current account's webroot
            find . -type f -exec chmod 0644 {} \;
    
            # change access for all folders in current account's webroot
            find . -type d -exec chmod 0755 {} \;
    
            echo Owner and file/dir access was changed for files/dirs in webroot
    
            $accountWebRoot=$rootDir/$accountName/$webRoot
        
            # Deactivate the Joomla FTP-layer where needed
            if [ -e $accountWebRoot/configuration.php ]; then
        
                cp $accountWebRoot/configuration.php $accountWebRoot/configuration_backup.php
        
                searchStr="ftp_enable = '1'"
                replaceStr="ftp_enable = '0'"
        
                sed "s/${searchStr}/${replaceStr}/g" <$accountWebRoot/configuration_backup.php >$accountWebRoot/configuration.php
        
                echo configuration.php was processed: Joomla FTP layer deactivated
            else
                echo configuration.php was not found for this account
            fi
    
        else
            echo a webroot was not found for this account, so no changes were done
        fi
    done
    

    copy | embed

    0 comments - tagged in  posted by torkil on Mar 16, 2010 at 8:20 a.m. EDT
  • Linux: Dateien nach Inhalt suchen
    find -type f|xargs grep $keyword
    

    copy | embed

    0 comments - tagged in  posted by cbeier on Mar 07, 2010 at 2:23 p.m. EST
  • install Drush from CVS HEAD on any unix server
    ##
    ## Installs Drush (the Drupal Shell command line utility) from CVS HEAD 
    ## on any UNIX machine, such that all users that have /usr/local/bin in
    ## their $PATH can use Drush (granted they have access to a Drupal install).
    ##
    ##
    
    cd /usr/local/src
    cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d drush-HEAD contributions/modules/drush/
    curl -O http://download.pear.php.net/package/Console_Table-1.1.3.tgz
    tar zxvf Console_Table-1.1.3.tgz
    cp Console_Table-1.1.3/Table.php drush-HEAD/includes/table.inc
    ln -s /usr/local/src/drush-HEAD/drush /usr/local/bin/drush
    
    ##
    ## now any user that has /usr/local/bin in their $PATH can use Drush.
    ##
    ##
    ## ... later on, to keep drush up to date, run the following:
    
    #cd /usr/local/src/drush-HEAD
    #cvs update -dPA
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Mar 05, 2010 at 11:38 a.m. EST
  • htaccess redirect all traffic to homepage
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . http://domain.tld/index.php [L]
    </IfModule>
    

    copy | embed

    0 comments - tagged in  posted by rendrag on Feb 06, 2010 at 1:49 p.m. EST
  • create ssh RSA id
    # Create an SSH id and public key pair (RSA) on your laptop/local machine
    mkdir ~/.ssh
    chmod 700 ~/.ssh
    ssh-keygen -q -f ~/.ssh/id_rsa -t rsa
    ## Enter passphrase (empty for no passphrase): …
    ## Enter same passphrase again: …
    
    # protect your SSH keys
    chmod go-w ~/
    chmod 700 ~/.ssh
    chmod go-rwx ~/.ssh/*
    
    # Send your public id to the server. 
    # @see http://snipt.net/jrguitar21/passwordless-rsa-ssh-1-liner/
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Jan 29, 2010 at 10:26 a.m. EST
  • install svn on shared host
    #Install subversion on a shared host
    
    
    curl -O http://subversion.tigris.org/downloads/subversion-1.6.9.tar.gz
    curl -O http://subversion.tigris.org/downloads/subversion-deps-1.6.9.tar.gz
    curl -O http://www.openssl.org/source/openssl-0.9.8l.tar.gz
    
    tar zxvf openssl-0.9.8l.tar.gz
    tar zxvf subversion-1.6.9.tar.gz
    tar zxvf subversion-deps-1.6.9.tar.gz
    
    cd openssl-0.9.8l/
    ./config shared --prefix=$HOME/installs && make clean && make && make install
    cd ../
    
    export CFLAGS="-O2 -g -I$HOME/installs/include"
    export LDFLAGS="-L$HOME/installs/lib"
    export CPP="gcc -E -I$HOME/installs/include"
    
    cd subversion-1.6.9/neon/
    ./configure --with-ssl=openssl --prefix=$HOME/installs
    cd ../
    ./configure --with-ssl --prefix=$HOME/installs --with-neon=$HOME/installs/bin/neon-config
    make clean && make && make install
    
    echo 'store-plaintext-passwords=no' >> ~/.subversion/servers
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Jan 28, 2010 at 8:01 p.m. EST
  • jython pervasive connection test
    import java.lang as lib_lang
    import java.sql as lib_sql
    
    jdriver       = "com.pervasive.jdbc.v2.Driver"  # Java source driver
    url           = "jdbc:pervasive://192.168.1.104:1583/PDB01"    # jdbc url
    user_name     = "dbadmin"    # Source user name
    password      = "password"  # Source user password 
    
    lib_lang.Class.forName(jdriver)          # Register the driver
    jdbc = lib_sql.DriverManager.getConnection(url, user_name, password)
    stmt = jdbc.createStatement()      # Create java statement
    dyn_task = "select * from TMP_TABLE"
    result_set = stmt.executeQuery(dyn_task)
    
    while result_set.next() > 0:
        print result_set.getString(1)
    

    copy | embed

    0 comments - tagged in  posted by bgulcu on Jan 18, 2010 at 7:00 a.m. EST
  • jython oracle connection test
    import java.lang as lib_lang
    import java.sql as lib_sql
    
    jdriver       = "oracle.jdbc.driver.OracleDriver"  # Java source driver
    url           = "jdbc:oracle:thin:@192.168.1.101:1521:ORCL"    # jdbc url
    user_name     = "ODS"    # Source user name
    password      = "password"  # Source user password 
    
    lib_lang.Class.forName(jdriver)          # Register the driver
    jdbc = lib_sql.DriverManager.getConnection(url, user_name, password)
    stmt = jdbc.createStatement()      # Create java statement
    dyn_task = "select sysdate from dual"
    result_set = stmt.executeQuery(dyn_task)
    
    while result_set.next() > 0:
        print result_set.getString(1)
    

    copy | embed

    0 comments - tagged in  posted by bgulcu on Jan 10, 2010 at 11:03 a.m. EST
  • start oracle db
    #!/bin/sh
    if [ "$1" = "start" ]; then
    	/u01/app/10g_r2/bin/dbstart
    	echo "startup;" > $HOME/tmp.sql
    	echo "exit;" >> $HOME/tmp.sql
    	sqlplus sys/password as sysdba @$HOME/tmp.sql
    	rm $HOME/tmp.sql
    else
    	if [ "$1" = "stop" ]; then
    		echo "shutdown;" > $HOME/tmp.sql
    		echo "exit;" >> $HOME/tmp.sql
    		sqlplus sys/password as sysdba @$HOME/tmp.sql
    		rm $HOME/tmp.sql
    		/u01/app/10g_r2/bin/dbshut
    	fi
    fi
    

    copy | embed

    0 comments - tagged in  posted by bgulcu on Jan 10, 2010 at 10:54 a.m. EST
  • remove .svn folders
    find . -name ".svn" -type d -exec rm -rf {} \;
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Jan 06, 2010 at 11:47 a.m. EST
  • detect linux distro
    #!/bin/sh
    # Detects which OS and if it is Linux then it will detect 
    # which Linux Distribution.
    
    OS=`uname -s`
    REV=`uname -r`
    MACH=`uname -m`
    
    GetVersionFromFile()
    {
    	VERSION=`cat $1 | tr "\n" ' ' | sed s/.*VERSION.*=\ // `
    }
    
    if [ "${OS}" = "SunOS" ] ; then
    	OS=Solaris
    	ARCH=`uname -p`	
    	OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
    elif [ "${OS}" = "AIX" ] ; then
    	OSSTR="${OS} `oslevel` (`oslevel -r`)"
    elif [ "${OS}" = "Linux" ] ; then
    	KERNEL=`uname -r`
    	if [ -f /etc/redhat-release ] ; then
    		DIST='RedHat'
    		PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
    		REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
    	elif [ -f /etc/SUSE-release ] ; then
    		DIST=`cat /etc/SUSE-release | tr "\n" ' '| sed s/VERSION.*//`
    		REV=`cat /etc/SUSE-release | tr "\n" ' ' | sed s/.*=\ //`
    	elif [ -f /etc/mandrake-release ] ; then
    		DIST='Mandrake'
    		PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
    		REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
    	elif [ -f /etc/debian_version ] ; then
    		DIST="Debian `cat /etc/debian_version`"
    		REV=""
    
    	fi
    	if [ -f /etc/UnitedLinux-release ] ; then
    		DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
    	fi
    	
    	OSSTR="${OS} ${DIST} ${REV}(${PSUEDONAME} ${KERNEL} ${MACH})"
    
    fi
    
    
    echo ${OSSTR}
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Jan 06, 2010 at 11:20 a.m. EST
  • Set up mail forwarding on linux
    # add a .forward file to your home directory
    touch .forward
    
    # add your email address
    vi .forward
    <user>@<mail>.com
    
    # change permission else it won't work
    chmod 600 .forward
    
    # test mail send, replace 'user' with your login
    mailx -s 'test from cluster' user < /dev/null
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Dec 17, 2009 at 10:19 a.m. EST
  • apache configure htaccess defaults
    #
    # AccessFileName: The name of the file to look for in each directory
    # for additional configuration directives.  See also the AllowOverride
    # directive.
    #
    AccessFileName .htaccess
    
    #
    # The following lines prevent .htaccess and .htpasswd files from being 
    # viewed by Web clients. 
    #
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Dec 15, 2009 at 7:59 a.m. EST
  • Bash Log Rotator
    #!/bin/bash
    
    ## GLOBAL CONFIGURATIONS
    LOGS=( [0]="/usr/home/morpheus/cron/cron.log" )
    DATE=$(date +"%y_%m_%d")
    
    for index in 0
    do
    	cp ${LOGS[index]} ${LOGS[index]}.${DATE}
    	gzip -m9 ${LOGS[index]}.${DATE}
    	cat /dev/null > ${LOGS[index]}
    	printf "Log file rotated :)\n ============== \n" > ${LOGS[index]}
    done
    

    copy | embed

    0 comments - tagged in  posted by john_clarke on Nov 29, 2009 at 12:32 a.m. EST
  • rsync over ssh
    rsync -e ssh -av username@server.example.com:remote_directory local_directory
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Nov 08, 2009 at 5:27 p.m. EST
  • java socket server
    try {
    	ServerSocket serverSocket = new ServerSocket(gameServerPort);
    	logger.info("server started");
    	int clientCount = 0;
    	while (true) {				
    		Socket socket = serverSocket.accept();
    		socket.setSoTimeout(IConstants.TIMEOUT);
    		activeSockets.add(socket);
    		if (activeSockets.size() >= maxClients) {
    			socket.close();
    			logger.error("number of max clients reached.");
    		} else {
    			int clientID = clientCount++;
    			logger.info("new client: " + clientCount);
    			new Client(clientID, socket);
    		}
    	}
    } catch (BindException e) {
    	logger.error("port " + gameServerPort + "already in use.");
    	System.exit(1);
    } catch (IOException e) {
    	logger.error("undefined error.");
    }
    

    copy | embed

    0 comments - tagged in  posted by khakulov on Oct 17, 2009 at 12:07 p.m. EDT
  • top twenty processes by memory
    ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | head -21
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Oct 13, 2009 at 2:49 p.m. EDT
  • ssh port forwarding
    #This forwards all localhost:1234 connections to google.com:80 through gimli
    ssh -L 1234:google.com:80 gimli.cs.berkeley.edu
    

    copy | embed

    0 comments - tagged in  posted by njoubert on Oct 07, 2009 at 3:29 p.m. EDT
  • SVN Delete mergeinfo on tree except root (the merge target)
    svn propdel --recursive svn:mergeinfo ./*
    

    copy | embed

    0 comments - tagged in  posted by turnbullm on Oct 06, 2009 at 7:31 p.m. EDT
  • Delete merge info tag
    svn propdel svn:mergeinfo "location"
    

    copy | embed

    0 comments - tagged in  posted by turnbullm on Oct 06, 2009 at 7:29 p.m. EDT
Sign up to create your own snipts, or login.