working on it ...

Filters

Explore Public Snippets

Sort by

Found 84k snippets

    public by helpi9007 modified Apr 8, 2018  447  2  3  0

    echo Error

    #!/bin/bash 
    function describe {
        echo "#########################################################"
        echo Usage: $0 {1 2}
        echo Usage: $0 {Exportfolder debug-log}
        echo Usage: example $0 {$HOME/Documents/Exportfolder $HOME/Destktop/$0/debug.log}
        echo " "
        echo This script will read the iTunes books from $STARTFOLDER
        echo "#########################################################"
        }
    
    
    START_temp=$HOME/Library/Containers/com.apple.BKAgentService 
    STARTFOLDER=$START_temp/Data/Documents/iBooks/Books   
        
    if [ -z "$1" ] || [ ! -d "$1" ]; then 
        echo >&2 "Error: You must supply the first argument as a directory!"
        describe
        exit 1
    elif [ -z "$2" ] || [  -d "$2" ]; then
        echo >&2 "Error: You must supply the second argument as a filename, not directory!"
        describe
        exit 1
    fi

    public by yourfriendcaspian modified Sep 2, 2017  328  3  4  0

    Installing nextcloud 12.0 on Debian GNU/Linux (sid) [lighttpd/mariadb]

    Installing nextcloud 12.0 on Debian GNU/Linux (sid) [lighttpd/mariadb]: nextcloud-install-sid.sh
    ### Written: 2017-06-13
    ### Updated: -
    
    ### Get, verify and unpack, delete and move the distribution package (12.0)
    wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.tar.bz2
    wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.tar.bz2.sha256
    sha256sum -c nextcloud-12.0.0.tar.bz2.sha256 < nextcloud-12.0.0.tar.bz2.sha256
    tar xvf nextcloud-12.0.0.tar.bz2 && rm nextcloud-12.0.0.tar.bz2
    sudo mv nextcloud /var/www/html
    
    ### required packages
    sudo aptitude install mariadb-server lighttpd php7.0-cgi php-fpm php-ctype php-gd php-iconv php-json php7.0-xml php7.0-xmlreader php7.0-xmlwriter php-mbstring php7.0-posix php-simplexml php7.0-zip php7.0-mysql
    ### optional packages
    sudo aptitude install mariadb-client php7.0-curl php7.0-fileinfo php7.0-bz2 php7.0-intl php7.0-mcrypt php7.0-exif php7.0-redis php7.0-imagick
    
    ### Enable fastcgi mod
    sudo lighttpd-enable-mod cgi fastcgi-php fastcgi-php
    sudo /etc/init.d/lighttpd restart
    
    ### Permissions
    sudo chown -R www-data:www-data /var/www/html/nextcloud/
    
    ### Install nextcloud using the occ installer
    cd /var/www/html/nextcloud/
    sudo -u www-data php occ  maintenance:install --database "mysql" --database-name "nextcloud"  --database-user "root" --database-pass "password" --admin-user "admin" --admin-pass "password"
    
    

    public by yourfriendcaspian modified Sep 2, 2017  278  1  3  0

    simple-init-script.sh

    simple-init-script.sh: simple-init-script.sh
    #!/bin/bash
    # from http://ubuntuserverguide.com/2012/06/how-to-installing-nginx-with-php5-and-mysql-support-on-ubuntu-server-12-04-lts.html
    
    PHP_SCRIPT=/usr/sbin/php-fastcgi
    FASTCGI_USER=www-data
    FASTCGI_GROUP=www-data
    PID_DIR=/var/run/php-fastcgi
    PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid
    RET_VAL=0
    case "$1" in
     start)
     if [[ ! -d $PID_DIR ]]
     then
     mkdir $PID_DIR
     chown $FASTCGI_USER:$FASTCGI_GROUP $PID_DIR
     chmod 0770 $PID_DIR
     fi
     if [[ -r $PID_FILE ]]
     then
     echo "php-fastcgi already running with PID `cat $PID_FILE`"
     RET_VAL=1
     else
     $PHP_SCRIPT
     RET_VAL=$?
     fi
     ;;
     stop)
     if [[ -r $PID_FILE ]]
     then
     kill `cat $PID_FILE`
     rm $PID_FILE
     RET_VAL=$?
     else
     echo "Could not find PID file $PID_FILE"
     RET_VAL=1
     fi
     ;;
     restart)
     if [[ -r $PID_FILE ]]
     then
     kill `cat $PID_FILE`
     rm $PID_FILE
     RET_VAL=$?
     else
     echo "Could not find PID file $PID_FILE"
     fi
     $PHP_SCRIPT
     RET_VAL=$?
     ;;
     status)
     if [[ -r $PID_FILE ]]
     then
     echo "php-fastcgi running with PID `cat $PID_FILE`"
     RET_VAL=$?
     else
     echo "Could not find PID file $PID_FILE, php-fastcgi does not appear to be running"
     fi
     ;;
     *)
     echo "Usage: php-fastcgi {start|stop|restart|status}"
     RET_VAL=1
     ;;
    esac
    exit $RET_VAL
    
    

    public by yourfriendcaspian modified Sep 2, 2017  207  0  3  0

    Commands to fix apt - E: Sub-process /usr/bin/dpkg returned an error code (1)

    Commands to fix apt - E: Sub-process /usr/bin/dpkg returned an error code (1): fix-apt-get.sh
    #!/bin/bash
    
    sudo rm -rf /var/lib/dpkg/info/*.*
    sudo apt-get autoremove
    sudo apt-get autoclean
    sudo apt-get update
    sudo apt-get upgrade
    
    

    public by yourfriendcaspian modified Sep 2, 2017  197  0  3  0

    Debian linux script for install Ruby on Rails, Postgres, and Passenger

    Debian linux script for install Ruby on Rails, Postgres, and Passenger: rails_install.sh
    # Ruby prerequisites
    sudo apt-get update
    sudo apt-get install -y git gcc make libssl-dev libreadline-dev zlib1g-dev
    
    # Native gem extensions prerequisites
    sudo apt-get install -y g++
    
    #Install Ruby using rvm
    sudo apt-get install -y libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
    curl -sSL https://get.rvm.io | bash -s stable
    source ~/.rvm/scripts/rvm
    rvm install 2.4.0
    rvm use 2.4.0 --default
    
    #Install bundler
    gem install --no-rdoc --no-ri bundler
    
    #Install nodejs
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    #Install rails
    gem install --no-rdoc --no-ri rails -v 5.1.1
    
    #Install Postgres
    sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
    wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
    sudo apt-get update
    sudo apt-get install -y postgresql-common
    sudo apt-get install -y postgresql-9.5 libpq-dev
    
    #Install Passenger
    ## Install our PGP key and add HTTPS support for APT
    sudo apt-get install -y dirmngr gnupg
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
    sudo apt-get install -y apt-transport-https ca-certificates
    
    ## Add our APT repository
    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    
    ## Install Passenger
    sudo apt-get install -y passenger
    
    #Finalize the rails setup
    bundle install
    
    

    public by yourfriendcaspian modified Sep 2, 2017  236  1  3  0

    simple script opening/closing sshfs connection with ./sshfs.sh -o or ./sshfs.sh -c

    simple script opening/closing sshfs connection with ./sshfs.sh -o or ./sshfs.sh -c: sshfs.sh
    #!/bin/bash
    
    if [ "$1" != "" ]; then
        case $1 in
            -o | --open )           echo "$USER opening sshfs connection"
                                    open your connection here
                                    ;;
            -c | --close )          echo "$USER closing sshfs connection"
                                    close your connection here
                                    ;;
            -h | --help )           echo "Use one of the options: -o/--open or -c/--close"
        esac
    else
        echo "No option chosen"
        echo "Use one of the options: -o/--open or -c/--close"
        exit 1
    fi
    
    
    

    public by yourfriendcaspian modified Sep 2, 2017  298  0  4  0

    How to install MySQL with Python and Django Debian/Derivatives

    #Install Mysql with Python and Django Debian/Derivatives 
    
    #To install we need to have some dependencies in the system for now we will show on
    #Debian and Derivatives.
    
    #But first install updates and MySQL
    
    ```
    $ sudo apt-get update
    $ sudo apt-get upgrade
    ```	
    
    # ** NOTE: ** 
    #Each System has its commands for updating, if your machine is not derived from Debian ** look for them **
    
    ##Install MySQL
    
    ```
    $ sudo apt-get install mysql-server mysql-client
    Passwd for 'root' user: <password>
    ```
    
    #At the end we execute this command to give more security to our BD
    
    ```
    $ mysql_secure_installation
    ```
    
    #Check carefully the changes that will be made, the first question is the passwd for root,
    #IF you want to keep or change it, and continue with other security questions.
    
    ##Create a database and a user for the DB
    
    #Now we will create the DB that will be connected to DJango and a User with Passwd to access it.
    #There are two ways to do this:
    
    ```
    echo "CREATE DATABASE <DATABASENAME>;" | mysql -u root -p
    echo "CREATE USER '<DATABASEUSER>'@'localhost' IDENTIFIED BY '<PASSWORD>';" | mysql -u root -p
    echo "GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@'localhost';" | mysql -u root -p
    echo "FLUSH PRIVILEGES;" | mysql -u root -p
    ```
    
    #So they should put their passwd of mysql in each line or
    #they can also do it of the following way
    
    ```
    $ mysql -u root -p
    ```
    
    #Enter your passwd and then do the following.
    
    ```
    CREATE DATABASE <DATABASENAME>;
    CREATE USER '<DATABASEUSER>'@localhost IDENTIFIED BY '<PASSWORD>';
    GRANT ALL PRIVILEGES ON <DATABASENAME>.* TO '<DATABASEUSER>'@localhost;
    FLUSH PRIVILEGES;
    exit
    ```
    
    #We Check Dependencies
    #There are only a few dependencies but you have to be sure
    
    ```
    $ sudo apt-get install libmysqlclient-dev python-dev
    ```
    
    #So far it's all just proceed to install pip in our virtual environment or globally
    
    ```
    $ sudo -H pip install mysql-python
    ```
    
    #As you can see now you can create DB and Users for each Django Project

    public by yourfriendcaspian modified Sep 2, 2017  269  0  4  0

    Linux Program Installs

    Random Linux program install commands
    # Install Postgres
     http://apt.postgresql.org/pub/repos/apt/ 9.4-pgdg main
    
    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
    sudo apt-get update
    sudo apt-get install postgresql-9.4
    
    # Install redis 
    curl -O http://download.redis.io/releases/redis-3.2.9.tar.gz
    tar xzf redis-3.2.9.tar.gz
    rm redis-3.2.9.tar.gz
    make -C redis-3.2.9
    
    # Install elasticsearch
    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.tar.gz
    tar -xvf elasticsearch-5.4.1.tar.gz
    
    # Install Enpass
    #echo "Download Enpass";
    #curl -O https://dl.sinew.in/linux/setup/5-5-3/Enpass_Installer_5.5.3
    
    #chmod +x Enpass_Installer_5.5.3
    #./Enpass_Installer_5.5.3
    
    #rm Enpass_Installer_5.5.3
    
    # Install oh-my-zsh
    sudo apt-get install zsh
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    
    # Install tmux
    sudo apt-get install tmux
    
    # Install Chrome
    #wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
    #sudo dpkg -i google-chrome*.deb
    
    #Install dotfiles
    #\curl https://raw.githubusercontent.com/nandosousafr/dotfiles/master/bootstrap.sh | bash
    
    #Install ELEMENTARY tweaks
    #sudo add-apt-repository ppa:mpstark/elementary-tweaks-daily
    #sudo apt-get update
    #sudo apt-get install elementary-tweaks				

    public by mateothegreat modified Aug 31, 2017  201  0  2  0

    Kubernetes term aliases

    Kubernetes term aliases: aliases.sh
    # Used to run minikube shortly
    alias mk="minikube"
    
    # Used to run kubectl shortly
    alias k="kubectl"
    
    # Used to get ...
    alias kg="kubectl get"
    
    # Used to get all pods
    alias kgp="kubectl get pods"
    
    # Used to get all pods with watching
    alias kgpw="watch kubectl get pods"
    
    # Used to create a resource
    kc() {
      kubectl create -f $1
    }
    
    # Used to delete a resource
    kd() {
      kubectl delete -f $1
    }
    
    # Used to re-create a resource
    # (Not replace or apply, juste re-create)
    kr() {
      kubectl delete -f $1
      kubectl create -f $1
    }
    
    # Used to kill a pod now!
    kpk() {
      ns="default"
      if [ -z "$2" ]; then
        ns=$2
      fi
      kubectl delete pod $1 --grace-period=0 --force --namespace=$ns
    }
    
    # Used to exec in a pod
    kpe() {
      ns="default"
      if [ -z "$3" ]; then
        ns=$3
      fi
      kubectl exec -it $1 -c $2 --namespace=$ns
    }
    
    # Used to find a pod name
    kpf() {
      ns="default"
      if [ -z "$2" ]; then
        ns=$2
      fi
      kubectl get pods --namespace=$ns | grep $1 | awk '{print $1}'
    }
    
    # Used to display and follow pod logs
    kpl() {
      ns="default"
      if [ -z "$3" ]; then
        ns=$3
      fi
      kubectl logs $1 -c $2 --namespace=$ns -f
    }
    
    

    public by yourfriendcaspian modified Aug 18, 2017  227  0  3  0

    Command Line Disk Benchmark

    Command Line Disk Benchmark: diskbench
    #!/bin/sh
    # This came from Greg V's dotfiles:
    #      https://github.com/myfreeweb/dotfiles
    # Feel free to steal it, but attribution is nice
    #
    # Thanks:
    #  http://www.amsys.co.uk/2013/blog/using-command-line-to-benchmark-disks/
    
    echo "Benchmarking write..."
    dd if=/dev/zero bs=2048k of=tstfile count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }'
    [ -e "`which purge`" ] && purge
    echo "Benchmarking read..."
    dd if=tstfile bs=2048k of=/dev/null count=1024 2>&1 | grep sec | awk '{print $1 / 1024 / 1024 / $5, "MB/sec" }'
    rm tstfile
    
    
    • Public Snippets
    • Channels Snippets