working on it ...

Filters

Explore Public Snippets

Sort by

Found 51 snippets

    public by yourfriendcaspian modified Sep 2, 2017  114  0  2  0

    Instructions for installing the most popular webdrivers, and then the latest version of the standalone Selenium server

    Instructions for installing the most popular webdrivers, and then the latest version of the standalone Selenium server: selenium-instructions.md
    # Steps For Setting Up Selenium And The Webdrivers
    
    ### Install The Firefox Geckodriver
    
    * Download [the latest Geckodriver for Firefox](https://github.com/mozilla/geckodriver/releases)
    * then `mv` that file to `/usr/local/bin/geckodriver` and `sudo chmod +x /usr/local/bin/geckodriver`
    * make sure you have `"webdriver.firefox.profile" : "geckodriver",` in your `nightwatch.json` file if you are using it
    
    ### Install The Chromedriver
    
    * Download the latest version [from the Chrome site](https://sites.google.com/a/chromium.org/chromedriver/downloads)
    * unzip it if it is a zip file
    * then `mv` that file to `/usr/local/bin/chromedriver` and `sudo chmod +x /usr/local/bin/chromedriver`
    
    ### Install the Safari Driver
    
    * Download the `SafariDriver.safariextz` [from the release site](http://selenium-release.storage.googleapis.com/index.html?path=2.45/)
    * Double click on the file and it will open in Safari
    * Accept the file as trusted
    * It will now show in your extensions
    
    ### Build the latest Selenium binary
    
    * `git clone git@github.com:SeleniumHQ/selenium.git`
    * `cd selenium`
    * `./go clean release`
    * `cd build/dist`
    * You can now run the server with the following: `java -jar selenium-server-standalone-3.0.0-beta1.jar`
    * _you may have a server of a different name depending on when you read this tutorial_
    
    ### Running the server
    
    * cd to the directory where you build the jar file
    * run: `java -jar selenium-server-standalone-3.0.0-beta1.jar`
    
    You can also alias the function in a `~/.bashrc` or `~/.zshrc` with:
    
    ```sh
    alias selenium="java -jar /path/to/build/dist/folder/selenium-server-standalone-3.0.0-beta1.jar"
    ```
    
    Remember: _You may have a server of a different name depending on when you read this tutorial_
    
    

    public by yourfriendcaspian modified Sep 2, 2017  104  0  1  0

    Cómo instalar MySql en Debian/derivados, crear Bases de Datos y Usuarios para usarlos en Django

    Cómo instalar MySql en Debian/derivados, crear Bases de Datos y Usuarios para usarlos en Django: Mysql and Django.md
    Instalar Mysql con Python y Django Debian/Derivados 
    =====================
     
     
    Para instalar necesitamos tener unas dependencias en el sistema por ahora mostraremos en equipos **Debian y Derivados**. Pero primero instalares actualizaciones y MySQL
     
     
    ----------
    Actualizaciones y MySQL
    ---------
     
    **Actualizar Sistema** lo hacemos con los siguientes comandos
     
    ```
    $ sudo apt-get update
    $ sudo apt-get upgrade
    ```
     
    > **NOTA:** Cada Sistema tiene sus comandos para actualización, si es que tu máquina no es derivada de Debian **buscalos** :D
     
    #### <i class="icon-file"></i> Instalación de MySQL
     
    Instalamos Mysql (5.5.*)
    ```
    $ sudo apt-get install mysql-server mysql-client
    Passwd for 'root' user: mypasswd
    ```
    Al final ejecutamos este comando para darle mas seguridad a nuestra BD
     
    ```
    $ mysql_secure_installation
    ```
    Revisar atentanmente los cambios que se harán, la primera pregunta es el passwd root
    SI desea mantenerla o cambiarla, y sigue con otras preguntas de seguridad.
     
     
    #### <i class="icon-folder-open"></i> Crear una base de datos y un usuario para la BD
     
    Ahora crearemos la BD a la que se conectara DJango y un Usuario con Passwd para que acceda a ella.
    Existen dos maneras de hacerlo:
    ```
    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
    ```
    Así deberan poner su passwd de mysql en cada línea ó también pueden hacerlo de la siguiente manera
     
    ```
    $ mysql -u root -p
    ```
    Introducen su passwd y a continuación hacen lo siguiente.
     
    ```
    CREATE DATABASE DATABASENAME;
    CREATE USER 'DATABASEUSER'@localhost IDENTIFIED BY 'PASSWORD';
    GRANT ALL PRIVILEGES ON DATABASENAME.* TO 'DATABASEUSER'@localhost;
    FLUSH PRIVILEGES;
    exit
    ```
     
    #### <i class="icon-pencil"></i> Verificamos Dependencias
     
    Sólo hay unas cuantas dependencias pero hay que estar seguros
     
    ```
    $ sudo apt-get install libmysqlclient-dev python-dev
    ```
     
    #### <i class="icon-trash"></i> Instalando driver mysql-python con PIP
     
    Hasta aquí es todo sólo procedemos a instalar Pip en nuestro entorno virtual o globalmente
     
    ```
    $ sudo pip install mysql-python
    ```
     
     
    ----------
    <i class="icon-hdd"></i> Resumen
    ---------
    Como podrás ver ahora puedes crear DB y Usuarios para cada Proyecto de Django.
     
    
     
     
     
     
    
    
    

    public by yourfriendcaspian modified Sep 2, 2017  111  0  2  0

    Install Mysql with Python and Django Debian/Derivatives - Translated

    Install Mysql with Python and Django Debian/Derivatives - Translated: mysql_python_on_debian.txt
    #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  87  1  1  0

    Unattended Ubuntu Install- Download a non graphical Ubuntu installation ISO

    Unattended Ubuntu Install- Download a non graphical Ubuntu installation ISO: ubuntu_unattended_install.md
    https://askubuntu.com/a/122506/209043
    
    
    wget http://www.instalinux.com/download/iso1132.iso -O /root/iso1132.iso
    wget http://www.instalinux.com/download/preseed1132.txt -O preseed.cfg
    
    
    ---
    
    
    The complete solution is:
    
    Remaster a CD, ie, download a non graphical ubuntu installation ISO (server or alternate installation CD), mount it
    
        $ sudo su -
        # mkdir -p /mnt/iso
        # mount -o loop ubuntu.iso /mnt/iso
    
    Copy the relevant files to a different directory
    
        # mkdir -p /opt/ubuntuiso
        # cp -rT /mnt/iso /opt/ubuntuiso
    
    Prevent the language selection menu from appearing
    
        # cd /opt/ubuntuiso
        # echo en >isolinux/lang
    
    Use GUI program to add a kickstart file named `ks.cfg`
    
        # apt-get install system-config-kickstart
        # system-config-kickstart # save file to ks.cfg
    
    To add packages for the installation, add a `%package` section to the `ks.cfg` kickstart file, append to the end of `ks.cfg` file something like this.
    
        %packages
        @ ubuntu-server
        openssh-server
        ftp
        build-essential
    
    This will install the ubuntu-server "bundle", and will add the `openssh-server`, `ftp` and `build-essential` packages.
    
    Add a preseed file, to suppress other questions
    
        # echo 'd-i partman/confirm_write_new_label boolean true
        d-i partman/choose_partition \
        select Finish partitioning and write changes to disk
        d-i partman/confirm boolean true' > ks.preseed
    
    Set the boot command line to use the kickstart and preseed files
    
        # vi isolinux/txt.cfg
    
    Search for
    
        label install
          menu label ^Install Ubuntu Server
          kernel /install/vmlinuz
          append  file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --
    
    add `ks=cdrom:/ks.cfg` and `preseed/file=/cdrom/ks.preseed` to the append line. You can remove the `quiet` and `vga=788` words. It should look like
    
          append file=/cdrom/preseed/ubuntu-server.seed \
             initrd=/install/initrd.gz \
             ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed --
    
    Now create a new iso
    
        # mkisofs -D -r -V "ATTENDLESS_UBUNTU" \
             -cache-inodes -J -l -b isolinux/isolinux.bin \
             -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
             -boot-info-table -o /opt/autoinstall.iso /opt/ubuntuiso
    
    That's it. You'll have a CD that would install an Ubuntu system once you boot from it, without requiring a single keystroke.
    
    
    ---
    
    
    To bypass the need to press enter on boot change the timeout value from `0` to `10` in `/isolinux/isolinux.cfg`: timeout `10` Note that a value of `10` represents `1` second
    
    
    
    ---
    
    # Last
    
    mkisofs -D -r -V "ATTENDLESS_UBUNTU"      -cache-inodes -J -l -b isolinux.bin      -c boot.cat -no-emul-boot -boot-load-size 4      -boot-info-table -o /root/autoinstall.iso /opt/ubuntuiso
    
    
    
    

    public by yourfriendcaspian modified Sep 2, 2017  73  0  1  0

    Provision Ubuntu 16.04 Server

    Provision Ubuntu 16.04 Server: ubuntu_server_provision.txt
    - Postgres
    sudo apt install postgresql
    
    move databases
    
    - Samba File Server
    https://help.ubuntu.com/lts/serverguide/samba-fileserver.html
    
    
    
    - Elastic Search
    
    https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-on-an-ubuntu-vps
    
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt install oracle-java8-installer
    
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.deb
    sudo dpkg -i elasticsearch-5.4.0.deb 
    
    - Logstash
    
    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    
    echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
    
    sudo apt install logstash=1:5.4.0-1 
    
    sudo systemctl stop logstash
    sudo systemctl start logstash
    sudo systemctl enable logstash
    
    - Kibana
    https://www.elastic.co/guide/en/kibana/current/deb.html
    
    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    
    sudo apt-get install apt-transport-https
    
    echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
    
    sudo systemctl enable kibana
    --------------------
    
    - Beats
    
    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    
    echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
    
    sudo apt-get update && sudo apt-get install filebeat
    
    # sudo update-rc.d filebeat defaults 95 10
    
    
    - Mongo
    https://docs.mongodb.com/manual/administration/production-notes/#kernel-and-file-systems
    https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
    
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
    echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
    sudo apt update
    
    apt cache madison mongodb-org
    sudo apt install mongodb-org=3.4.4
    
    move databases
    
    -----------
    
    - Neo4j
    https://neo4j.com/download/community-edition/
    
    sudo wget https://neo4j.com/artifact.php?name=neo4j-community-3.2.0-unix.tar.gz
    
    
    https://www.digitalocean.com/community/tutorials/how-to-install-neo4j-on-an-ubuntu-vps
    
    wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -
    echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list
    sudo apt update
    
    apt-cache madison neo4j | head
    sudo apt install neo4j=3.2.0
    
    
    ## nginx 
    
    apt-cache madison nginx 
    
         nginx | 1.10.0-0ubuntu0.16.04.4 | http://tr.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
         nginx | 1.10.0-0ubuntu0.16.04.4 | http://tr.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
         nginx | 1.10.0-0ubuntu0.16.04.4 | http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
         nginx | 1.10.0-0ubuntu0.16.04.4 | http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
         nginx | 1.9.15-0ubuntu1 | http://tr.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
         nginx | 1.9.15-0ubuntu1 | http://tr.archive.ubuntu.com/ubuntu xenial/main i386 Packages
    
    
    apt install nginx=1.10.0-0ubuntu0.16.04.4
    
    
    ----------------------------------------
    
    - Docker 
    https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository
    
    ahmed@ubuntuserver:~$ apt-cache madison docker-ce
     docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
     docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
    
    sudo apt install docker-ce=17.03.1~ce-0~ubuntu-xenial
    
    - Docker Machine Host
    
    docker-machine create --driver none --url=tcp://192.168.1.21:2376 default
    docker-machine regenerate-certs default
    
    
    - KVM
    
    https://help.ubuntu.com/community/KVM/Installation
    
    sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
    
    
    sudo apt-get install nmap
    
    sudo apt install python-setuptools
    sudo apt install python-pip
    
    
    
    - Influx Time Series DB
    
    
    docker pull telegraf:1.3-alpine
    wget https://dl.influxdata.com/telegraf/releases/telegraf_1.3.1-1_amd64.deb
    sudo dpkg -i telegraf_1.3.1-1_amd64.deb
    
    docker pull influxdb:1.2-alpine
    wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.4_amd64.deb
    sudo dpkg -i influxdb_1.2.4_amd64.deb
    
    docker pull quay.io/influxdb/chronograf:1.3.1.0
    wget https://dl.influxdata.com/chronograf/releases/chronograf_1.3.1.0_amd64.deb
    sudo dpkg -i chronograf_1.3.1.0_amd64.deb
    
    
    docker pull kapacitor:1.3.1-alpine
    wget https://dl.influxdata.com/kapacitor/releases/kapacitor_1.3.1_amd64.deb
    sudo dpkg -i kapacitor_1.3.1_amd64.deb
    
    
    
    
    

    public by yourfriendcaspian modified Sep 2, 2017  65  0  1  0

    Raspberry Pi VPN Router

    Raspberry Pi VPN Router: raspberry-pi-vpn-router.md
    # Raspberry Pi VPN Router
    
    This is a quick-and-dirty guide to setting up a Raspberry Pi as a "[router on a stick](https://en.wikipedia.org/wiki/One-armed_router)" to [PrivateInternetAccess](http://privateinternetaccess.com/) VPN.
    
    ## Requirements
    
    Install Raspbian Jessie (`2016-05-27-raspbian-jessie.img`) to your Pi's sdcard.
    
    Use the **Raspberry Pi Configuration** tool or `sudo raspi-config` to:
    
    * Expand the root filesystem and reboot
    * Boot to commandline, not to GUI
    * Configure the right keyboard map and timezone
    * Configure the Memory Split to give 16Mb (the minimum) to the GPU
    * Consider overclocking to the Medium (900MHz) setting on Pi 1, or High (1000MHz) setting on Pi 2
    
    ## IP Addressing
    
    My home network is setup as follows:
    
    * Internet Router: `192.168.1.1`
    * Subnet Mask: `255.255.255.0`
    * Router gives out DHCP range: `192.168.100-200`
    
    If your network range is different, that's fine, use your network range instead of mine.
    
    I'm going to give my Raspberry Pi a static IP address of `192.168.1.2` by configuring `/etc/network/interfaces` like so:
    
    ~~~
    auto lo
    iface lo inet loopback
    
    auto eth0
    allow-hotplug eth0
    iface eth0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8 8.8.4.4
    ~~~
    
    You can use WiFi if you like, there are plenty tutorials around the internet for setting that up, but this should do:
    
    ~~~
    auto lo
    iface lo inet loopback
    
    auto eth0
    allow-hotplug eth0
    iface eth0 inet manual
    
    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet static
        wpa-ssid "Your SSID"
        wpa-psk  "Your Password"
        address 192.168.1.2
        netmask 255.255.255.0
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8 8.8.4.4
    ~~~
    
    You only need one connection into your local network, don't connect both Ethernet and WiFi. I recommend Ethernet if possible.
    
    ## NTP
    
    Accurate time is important for the VPN encryption to work. If the VPN client's clock is too far off, the VPN server will reject the client.
    
    You shouldn't have to do anything to set this up, the `ntp` service is installed and enabled by default.
    
    Double-check your Pi is getting the correct time from internet time servers with `ntpq -p`, you should see at least one peer with a `+` or a `*` or an `o`, for example:
    
    ~~~
    $ ntpq -p
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    -0.time.xxxx.com 104.21.137.30    2 u   47   64    3  240.416    0.366   0.239
    +node01.jp.xxxxx 226.252.532.9    2 u   39   64    7  241.030   -3.071   0.852
    *t.time.xxxx.net 104.1.306.769    2 u   38   64    7  127.126   -2.728   0.514
    +node02.jp.xxxxx 250.9.592.830    2 u    8   64   17  241.212   -4.784   1.398
    ~~~
    
    ## Setup VPN Client
    
    Install the OpenVPN client:
    
    ~~~
    sudo apt-get install openvpn
    ~~~
    
    Download and uncompress the PIA OpenVPN profiles:
    
    ~~~
    wget https://www.privateinternetaccess.com/openvpn/openvpn.zip
    sudo apt-get install unzip
    unzip openvpn.zip -d openvpn
    ~~~
    
    Copy the PIA OpenVPN certificates and profile to the OpenVPN client:
    
    ~~~
    sudo cp openvpn/ca.rsa.2048.crt openvpn/crl.rsa.2048.pem /etc/openvpn/
    sudo cp openvpn/Japan.ovpn /etc/openvpn/Japan.conf
    ~~~
    
    You can use a diffrent VPN endpoint if you like. Note the extension change from **ovpn** to **conf**.
    
    Create `/etc/openvpn/login` containing only your username and password, one per line, for example:
    
    ~~~
    user12345678
    MyGreatPassword
    ~~~
    
    Change the permissions on this file so only the root user can read it:
    
    ~~~
    sudo chmod 600 /etc/openvpn/login
    ~~~
    
    Setup OpenVPN to use your stored username and password by editing the the config file for the VPN endpoint:
    
    ~~~
    sudo nano /etc/openvpn/Japan.conf
    ~~~
    
    Change the following lines so they go from this:
    
    ~~~
    ca ca.rsa.2048.crt
    auth-user-pass
    crl-verify crl.rsa.2048.pem
    ~~~
    
    To this:
    
    ~~~
    ca /etc/openvpn/ca.rsa.2048.crt
    auth-user-pass /etc/openvpn/login
    crl-verify /etc/openvpn/crl.rsa.2048.pem
    ~~~
    
    ## Test VPN
    
    At this point you should be able to test the VPN actually works:
    
    ~~~
    sudo openvpn --config /etc/openvpn/Japan.conf
    ~~~
    
    If all is well, you'll see something like:
    
    ~~~
    $ sudo openvpn --config /etc/openvpn/Japan.conf 
    Sat Oct 24 12:10:54 2015 OpenVPN 2.3.4 arm-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Dec  5 2014
    Sat Oct 24 12:10:54 2015 library versions: OpenSSL 1.0.1k 8 Jan 2015, LZO 2.08
    Sat Oct 24 12:10:54 2015 UDPv4 link local: [undef]
    Sat Oct 24 12:10:54 2015 UDPv4 link remote: [AF_INET]123.123.123.123:1194
    Sat Oct 24 12:10:54 2015 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
    Sat Oct 24 12:10:56 2015 [Private Internet Access] Peer Connection Initiated with [AF_INET]123.123.123.123:1194
    Sat Oct 24 12:10:58 2015 TUN/TAP device tun0 opened
    Sat Oct 24 12:10:58 2015 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
    Sat Oct 24 12:10:58 2015 /sbin/ip link set dev tun0 up mtu 1500
    Sat Oct 24 12:10:58 2015 /sbin/ip addr add dev tun0 local 10.10.10.6 peer 10.10.10.5
    Sat Oct 24 12:10:59 2015 Initialization Sequence Completed
    ~~~
    
    Exit this with **Ctrl+c**
    
    ## Enable VPN at boot
    
    ~~~
    sudo systemctl enable openvpn@Japan
    ~~~
    
    ## Setup Routing and NAT
    
    Enable IP Forwarding:
    
    ~~~
    echo -e '\n#Enable IP Routing\nnet.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.conf
    sudo sysctl -p
    ~~~
    
    Setup NAT fron the local LAN down the VPN tunnel:
    
    ~~~
    sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
    sudo iptables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    sudo iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
    ~~~
    
    Make the NAT rules persistent across reboot:
    
    ~~~
    sudo apt-get install iptables-persistent
    ~~~
    
    The installer will ask if you want to save current rules, select **Yes**
    
    If you don't select yes, that's fine, you can save the rules later with `sudo netfilter-persistent save`
    
    Make the rules apply at startup:
    
    ~~~
    sudo systemctl enable netfilter-persistent
    ~~~
    
    ## VPN Kill Switch
    
    This will block outbound traffic from the Pi so that only the VPN and related services are allowed.
    
    Once this is done, the only way the Pi can get to the internet is over the VPN.
    
    This means if the VPN goes down, your traffic will just stop working, rather than end up routing over your regular internet connection where it could become visible.
    
    ~~~
    sudo iptables -A OUTPUT -o tun0 -m comment --comment "vpn" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p icmp -m comment --comment "icmp" -j ACCEPT
    sudo iptables -A OUTPUT -d 192.168.1.0/24 -o eth0 -m comment --comment "lan" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p udp -m udp --dport 1198 -m comment --comment "openvpn" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p tcp -m tcp --sport 22 -m comment --comment "ssh" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p udp -m udp --dport 123 -m comment --comment "ntp" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p udp -m udp --dport 53 -m comment --comment "dns" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 53 -m comment --comment "dns" -j ACCEPT
    sudo iptables -A OUTPUT -o eth0 -j DROP
    ~~~
    
    And save so they apply at reboot:
    
    ~~~
    sudo netfilter-persistent save
    ~~~
    
    If you find traffic on your other systems stops, then look on the Pi to see if the VPN is up or not.
    
    You can check the status and logs of the VPN client with:
    
    ~~~
    sudo systemctl status openvpn@Japan
    sudo journalctl -u openvpn@Japan
    ~~~
    
    ## Configure Other Systems on the LAN
    
    Now we're ready to tell other systems to send their traffic through the Raspberry Pi.
    
    Configure other systems' network so they are like:
    
    * Default Gateway: Pi's static IP address (eg: `192.168.1.2`)
    * DNS: Something public like Google DNS (`8.8.8.8` and `8.8.4.4`)
    
    Don't use your existing internet router (eg: `192.168.1.1`) as DNS, or your DNS queries will be visible to your ISP and hence may be visible to organizations who wish to see your internet traffic.
    
    ## Optional: DNS on the Pi
    
    To ensure all your DNS goes through the VPN, you could install `dnsmasq` on the Pi to accept DNS requests from the local LAN and forward requests to external DNS servers.
    
    ~~~
    sudo apt-get install dnsmasq
    ~~~
    
    You may now configure the other systems on the LAN to use the Pi (`192.168.1.2`) as their DNS server as well as their gateway.
    
    

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

    Random Linux program install commands

    Random Linux program install commands: command_line_app_installs.txt
    # 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 yourfriendcaspian modified Sep 2, 2017  46  1  2  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  48  0  1  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  41  0  1  0

    PostgreSQL - full-text search configuration

    PostgreSQL - full-text search configuration: pg_search_conf_unaccented.sql
    -- enable extensions
    -- full-text search on postgresql
    CREATE EXTENSION unaccent;
    
    -- languages supported
    CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
    ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, french_stem;
    
    CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
    ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, english_stem;
    
    CREATE TEXT SEARCH CONFIGURATION de ( COPY = german );
    ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, german_stem;
    
    CREATE TEXT SEARCH CONFIGURATION nl ( COPY = dutch );
    ALTER TEXT SEARCH CONFIGURATION nl ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, dutch_stem;
    
    CREATE TEXT SEARCH CONFIGURATION da ( COPY = danish );
    ALTER TEXT SEARCH CONFIGURATION da ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, danish_stem;
    
    CREATE TEXT SEARCH CONFIGURATION fi ( COPY = finnish );
    ALTER TEXT SEARCH CONFIGURATION fi ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, finnish_stem;
    
    CREATE TEXT SEARCH CONFIGURATION hu ( COPY = hungarian );
    ALTER TEXT SEARCH CONFIGURATION hu ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, hungarian_stem;
    
    CREATE TEXT SEARCH CONFIGURATION it ( COPY = italian );
    ALTER TEXT SEARCH CONFIGURATION it ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, italian_stem;
    
    CREATE TEXT SEARCH CONFIGURATION no ( COPY = norwegian );
    ALTER TEXT SEARCH CONFIGURATION no ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, norwegian_stem;
    
    CREATE TEXT SEARCH CONFIGURATION pt ( COPY = portuguese );
    ALTER TEXT SEARCH CONFIGURATION pt ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, portuguese_stem;
    
    CREATE TEXT SEARCH CONFIGURATION ro ( COPY = romanian );
    ALTER TEXT SEARCH CONFIGURATION ro ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, romanian_stem;
    
    CREATE TEXT SEARCH CONFIGURATION ru ( COPY = russian );
    ALTER TEXT SEARCH CONFIGURATION ru ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, russian_stem;
    
    CREATE TEXT SEARCH CONFIGURATION es ( COPY = spanish );
    ALTER TEXT SEARCH CONFIGURATION es ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, spanish_stem;
    
    CREATE TEXT SEARCH CONFIGURATION sv ( COPY = swedish );
    ALTER TEXT SEARCH CONFIGURATION sv ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, swedish_stem;
    
    CREATE TEXT SEARCH CONFIGURATION tr ( COPY = turkish );
    ALTER TEXT SEARCH CONFIGURATION tr ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, turkish_stem;
    
    CREATE TEXT SEARCH CONFIGURATION usimple ( COPY = simple );
    ALTER TEXT SEARCH CONFIGURATION usimple ALTER MAPPING
    FOR hword, hword_part, word WITH unaccent, simple;
    
    
    • Public Snippets
    • Channels Snippets