Created: 2015-11-03 16:59
Updated: 2019-03-08 11:58

Bash Scripts

Misc. bash scripts that i write mostly for fun. These are written for good practice, for tasks i occassionally need to do that involve multiple steps.

Scripts are sorted into folders according to their general purpose.

├── backups
│   └──
├── install
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   ├──
│   └──
├── misc
│   └──
└── setup

4 directories, 20 files

Copies /var/lib/mysql from remote server to local /var/lib/mysql directory, essentially copying all MySQL Databases with Users and Permissions, and logs the progress in a text file.

Install Apache, MySQL, PHP and phpMyAdmin

  • requires no user input
  • sets a MySQL password and shows in console
  • does not overwrite the MySQL password if it is already set
curl | bash

  • Installs Homebrew if not installed
  • Installs XCode Command Line Tools if not installed
  • Installs Apache with Homebrew
  • Creates ~/Sites directory if not exists
  • Confgiures Apache conf file using sed
  • Confgiures Apache Virtual Hosts
  • Installs PHP with Homebrew
  • Installs common PHP Extensions (e.g. mcrypt required by OpenCart)
  • Confgiures PHP conf file using sed
  • Installs MariaDB with Homebrew
  • Installs Sequel-Pro with Homebrew Cask
  • Installs Dnsmasq with Homebrew and configures it

A rough script that takes care of all the steps in installing and setting up a Flask project. There are variables you can edit before running the script. At present, the script does the following:

  • apt Update and Upgrade
  • installs apache2
  • installs and enables libapache2-mod-wsgi
  • installs pip
  • installs and activates virtualenv
  • creates and enables VirtualHost file
  • creates .wsgi script
  • creates
  • restarts Apache

To run, simply do bash To run remotely:

curl -s | bash

Installs Froxlor Server Management Panel.

What it does:

  • adds Froxlor repo
  • adds Froxlor approve key for packages
  • updates system
  • installs Froxlor
  • sets directory permissions
  • provides a link to continue with web install

Execute remotely:

curl -s | bash

Note: LAMP needs to be installed already

imgcat is a script that previews images and GIFs right in the Terminal. You can see a gif in the Terminal with img foo.gif or a jpeg with img bar.jpg..

  • Sets alias img
  • Adds to $PATH

To run, simply do bash To run remotely:

curl -s | bash

Installs ionCube loader on a Debain Ubuntu system. May require some testing, don't remember if it worked flawlessly.

Removes the pre-installed Node.js on Raspbery Pi (Raspbian Jessy) and installs the latest release. The script:

  • Uninstalls nodejs, nodejs-legacy, nodered and npm
  • Downloads latest release from Heroku servers
  • Installs latest Node.js release for ARM computers (i.e. Raspberry Pi)
  • Cleans up temporary install files and autoremove
  • Confirms successful install and Node.js version

To run, simply do bash To run remotely:

curl -s | bash

Installs Node Version Manager and Node LTS version.

NOTE: I stopped working with OpenCart years ago and haven't looked at this scrip in a very long time. May not work as expected anymore..

Installs any opencart version between 1.5.6 and The script:

  • Asks for a specific version to install
  • Downloads and extracts the compressed files for that version from OpenCart's Github release archive
  • renames the .htaccess file

To finish the installation, go to /install in your browser (

To run, simply do bash To run remotely:

curl -s | bash

  • Adds Sublime HQ repo for both Sublime Text and Sublime Merge (it's the same repo for both)
  • Installs Sublime Text
  • Installs Sublime Merge
curl -s | bash

Same as install/, just different install directory. Uses a folder_name variable that can be customized by editing the script.


curl -s | bash -s

The default install location is: ~/todo

Installs todo.txt - a minimal command line based todo application - in the default Dropbox folder on a Mac. Also configures the recommended tweaks.

The tweaks are:

  • Sets alias t
  • Sets command and alias auto-completion
  • Sets $PATH
  • Sets default action TODOTXT_DEFAULT_ACTION
  • Sets output by priority and then number TODOTXT_SORT_COMMAND

The install location is: ~/Dropbox/todo

Requires: wget

Execute script remotely:

curl -s | bash -s

Installs Webmin on Debian. Adds Webmin to sources.list, adds GPG key, updates apt and installs Webmin. Also adds a rule for Webmin in UFW.

curl -s | bash

  • Installs Yarn dependency manager for Node.
  • Adds the install location to PATH

  • Renames all image files in the current folder in snake_case

The file extensions (jpeg/jpg/png) can easily be updated or removed.

curl -s | bash

Installs common dev tools for macOS using Homebrew and Casks. Needs to be updated to add more tools but a good functional starting point.

Creates a virtual host file. The script can take one or more argument in the form of domain name, like e.g:


For every domain, the script:

  • creates directory structure
  • grants permissions
  • creates demo index.html for virtual host
  • creates new virtual host file
  • enables the new virtual host file

The script also restarts Apache after all domains are set up.

Execute remotely:

curl -s | bash -s


  • The PHPINIDir directive in the virtual host conf file will give an Apache config test failed error if PHP is not installed on the system. Either install PHP (why not?) or remove the directive.
  • Sets the directory ownership for the user who ran the script
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more