mirror of
https://github.com/cytopia/devilbox.git
synced 2025-04-12 05:19:57 +00:00
Merge pull request #115 from cytopia/DVL-012-customise-bash
DVL-012 be able to customize bash config files
This commit is contained in:
commit
0c4290b0c4
4
.gitignore
vendored
4
.gitignore
vendored
@ -53,6 +53,10 @@
|
||||
/mod/php-fpm-7.2/*.so
|
||||
/mod/hhvm-latest/*.so
|
||||
|
||||
# Ignore custom bash and other confi files
|
||||
/bash/*
|
||||
!/bash/bashrc.sh-example
|
||||
!/bash/README.md
|
||||
|
||||
######################################
|
||||
# GENERIC
|
||||
|
@ -165,15 +165,16 @@ Every single attachable container comes with many different versions. In order t
|
||||
|
||||
#### Enter the container
|
||||
|
||||
You can also work directly inside the php container. Simply use the bundled scripts `bash.sh` or `root_bash.sh`. The `PS1` will automatically be populated with current chosen php version.
|
||||
You can also work directly inside the php container. Simply use the bundled scripts `shell.sh`. The `PS1` will automatically be populated with current chosen php version.
|
||||
```shell
|
||||
# Enter as user devilbox (normal operation / development)
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
devilbox@php-7.0.19 in /shared/httpd $
|
||||
```
|
||||
```shell
|
||||
# Enter as root user (do root stuff)
|
||||
host> ./root_bash.sh
|
||||
host> ./shell.sh
|
||||
devilbox@php-7.0.19 in /shared/httpd $ sudo su -
|
||||
root@php-7.0.19 in /shared/httpd $
|
||||
```
|
||||
|
||||
|
0
bash/README.md
Normal file
0
bash/README.md
Normal file
14
bash/bashrc.sh-example
Normal file
14
bash/bashrc.sh-example
Normal file
@ -0,0 +1,14 @@
|
||||
# Bashrc folder
|
||||
#
|
||||
# 1. This folder will be mounted to /etc/bashrc-devilbox.d
|
||||
# 2. All files ending by *.sh will be sourced by bash automatically
|
||||
# for the devilbox and root user.
|
||||
#
|
||||
|
||||
|
||||
# Add your custom vimrc and always load it with vim.
|
||||
# Also make sure you add vimrc to this folder.
|
||||
alias vim='vim -u /etc/bashrc-devilbox.d/vimrc
|
||||
|
||||
|
||||
|
@ -185,6 +185,9 @@ services:
|
||||
# to load custom PHP modules
|
||||
- ${DEVILBOX_PATH}/mod/${PHP_SERVER}:/usr/lib64/php/custom-modules:ro
|
||||
|
||||
# Mount devilbox user-defined bash config
|
||||
- ${DEVILBOX_PATH}/bash:/etc/bashrc-devilbox.d
|
||||
|
||||
# Mount custom mass virtual hosting
|
||||
# (configured in /etc/${HTTPD_SERVER}/02-vhost-mass.conf)
|
||||
- ${HOST_PATH_HTTPD_DATADIR}:/shared/httpd
|
||||
|
@ -81,7 +81,7 @@ There are many different options to backup your MySQL database including some fo
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the backup
|
||||
devilbox@php-7.1.6 in /shared/httpd $ mysqldump-secure
|
||||
@ -209,7 +209,7 @@ To find out more about the configuration and options of mysqldump-secure, visit
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the backup
|
||||
devilbox@php-7.1.6 in /shared/httpd $ mysqldump -h mysql -u root -p my_db_name > /shared/backups/mysql/my_db_name.sql
|
||||
@ -239,7 +239,7 @@ In order to restore or import mysql databases on the command line, you need to u
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ mysql -h mysql -u root -p my_db_name < /shared/backups/mysql/my_db_name.sql
|
||||
@ -249,7 +249,7 @@ devilbox@php-7.1.6 in /shared/httpd $ mysql -h mysql -u root -p my_db_name < /sh
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/mysql/my_db_name.sql.gz | mysql -h mysql -u root -p my_db_name
|
||||
@ -259,7 +259,7 @@ devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/mysql/my_db_name.sql.
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/mysql/my_db_name.sql.tar.gz | mysql -h mysql -u root -p my_db_name
|
||||
@ -284,7 +284,7 @@ devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/mysql/my_db_name.
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ pg_dump -h pgsql -U postgres -W my_db_name > /shared/backups/pgsql/my_db_name.sql
|
||||
@ -308,7 +308,7 @@ In order to restore or import PostgreSQL databases on the command line, you need
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ psql -h pgsql -U postgres -W my_db_name < /shared/backups/pgsql/my_db_name.sql
|
||||
@ -318,7 +318,7 @@ devilbox@php-7.1.6 in /shared/httpd $ psql -h pgsql -U postgres -W my_db_name <
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/pgsql/my_db_name.sql.gz | psql -h pgsql -U postgres -W my_db_name
|
||||
@ -328,7 +328,7 @@ devilbox@php-7.1.6 in /shared/httpd $ zcat /shared/backups/pgsql/my_db_name.sql.
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the import
|
||||
devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/pgsql/my_db_name.sql.tar.gz | psql -h pgsql -U postgres -W my_db_name
|
||||
@ -349,7 +349,7 @@ devilbox@php-7.1.6 in /shared/httpd $ tar xzOf /shared/backups/pgsql/my_db_name.
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the dump into /shared/backups/mongo
|
||||
devilbox@php-7.1.6 in /shared/httpd $ mongodump --out /shared/backups/mongo
|
||||
@ -365,7 +365,7 @@ To find out more about the configuration and options of mongodump, visit its pro
|
||||
|
||||
```shell
|
||||
# Enter the Container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# Start the restore/import from /shared/backups/mongo
|
||||
devilbox@php-7.1.6 in /shared/httpd $ mongorestore /shared/backups/mongo
|
||||
|
@ -23,8 +23,9 @@ Configure |
|
||||
2. [The devilbox `cfg/` directory](#12-the-devilbox-cfg-directory)
|
||||
3. [The devilbox `mod/` directory](#13-the-devilbox-mod-directory)
|
||||
1. [Custom PHP module example](#134-custom-php-module-example)
|
||||
4. [The operating system `hosts` file](#14-the-operating-system-hosts-file)
|
||||
5. [The operating system `resolv.conf` file](#15-the-operating-system-resolvconf-file)
|
||||
4. [The devilbox `bash/` directory](#14-the-devilbox-bash-directory)
|
||||
5. [The operating system `hosts` file](#15-the-operating-system-hosts-file)
|
||||
6. [The operating system `resolv.conf` file](#16-the-operating-system-resolvconf-file)
|
||||
2. [Devilbox general settings](#2-devilbox-general-settings)
|
||||
1. [Verbosity](#21-verbosity)
|
||||
2. [Devilbox base path](#22-devilbox-base-path)
|
||||
@ -43,6 +44,7 @@ Configure |
|
||||
3. [php.ini](#423-phpini)
|
||||
4. [HHVM](#424-hhvm)
|
||||
5. [Custom PHP modules](#425-custom-php-modules)
|
||||
6. [Customize bash and other tools](#426-customize-bash-and-other-tools)
|
||||
3. [Apache / Nginx](#43-apache--nginx)
|
||||
1. [Select Httpd version](#431-select-httpd-version)
|
||||
2. [Host port](#432-host-port)
|
||||
@ -176,13 +178,19 @@ zend_extension = /usr/lib64/php/custom-modules/ioncube_loader_lin_7.0.so
|
||||
|
||||
**Note:** PHP configuration files are loaded by file names in alphabetical order and the ioncube zend extension needs to be loaded before any other zend extension. This is the reason why its configuration file name starts with `00-`.
|
||||
|
||||
#### 1.4 The operating system `hosts` file
|
||||
#### 1.4 The devilbox `bash/` directory
|
||||
|
||||
Inside the devilbox root directory you will find a folder called `bash/`. Every file inside this folder ending by `*.sh` will be source by your bash, allowing for a customized bash configuration. All files not ending by `*.sh` will be ignored and can be used to create config files for other programs.
|
||||
|
||||
The `bash/` folder will be mounted into the PHP/HHVM container to `/etc/bashrc-devilbox.d/`.
|
||||
|
||||
#### 1.5 The operating system `hosts` file
|
||||
|
||||
On Linux and OSX your hosts file is located at `/etc/hosts` on Windows it will be at `C:\Windows\System32\drivers\etc`. Use this file to setup custom DNS entries if you are not using Auto-DNS.
|
||||
|
||||
Read up on it below at `/etc/hosts` or `Auto-DNS` section.
|
||||
|
||||
#### 1.5 The operating system `resolv.conf` file
|
||||
#### 1.6 The operating system `resolv.conf` file
|
||||
|
||||
This file is used to add the devilbox DNS server for Auto-DNS.
|
||||
|
||||
@ -444,6 +452,52 @@ zend_extension = /usr/lib64/php/custom-modules/ioncube_loader_lin_7.0.so
|
||||
|
||||
**Note:** PHP configuration files are loaded by file names in alphabetical order and the ioncube zend extension needs to be loaded before any other zend extension. This is the reason why its configuration file name starts with `00-`.
|
||||
|
||||
##### 4.2.6 Customize bash and other tools
|
||||
|
||||
The devilbox supports to load custom configuration files for your Docker containers bash. Put any file ending by `*.sh` into the `bash/` folder and they will automatically be sourced by your container's bash. It is also possible to add any other configuration files into that folder and start your app with the appended configuration path. To better understand how that works, have a look at the paths:
|
||||
|
||||
| Docker | bash host path | Path inside Docker container |
|
||||
|---------|----------------------------|------------------------|
|
||||
| PHP 5.4 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| PHP 5.5 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| PHP 5.6 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| PHP 7.0 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| PHP 7.1 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| PHP 7.2 | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
| HHVM | `bash/<cfg>.sh` | `/etc/bashrc-devilbox.d/<cfg>.sh` |
|
||||
|
||||
So lets assume you also want to change your vim configuration and have vim always use that specific config file during startup. This is achieved by placing the vim config file into that directory and create a bash alias, that always starts vim with that config file:
|
||||
|
||||
On your host system do the following:
|
||||
|
||||
```shell
|
||||
# Create your vim config in the devilbox bash directory `my-vimrc`
|
||||
$ vim bash/my-vimrc
|
||||
```
|
||||
```vim
|
||||
" You vim
|
||||
set encoding=utf-8 " The encoding displayed
|
||||
set nocompatible " Use vim defaults instead of vi defaults
|
||||
set autoread " Automatically reload file contents when changed from outside
|
||||
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
|
||||
set hidden " Start new file with :e without having to save current
|
||||
set history=50 " Remember commands entered in :
|
||||
set undolevels=100 " Use many levels of undo
|
||||
set shell=$SHELL " Set Shell
|
||||
set more " to show pages using `more` in command outpouts
|
||||
set title " show vim in terminal title
|
||||
```
|
||||
|
||||
Now add a custom bash config and create an alias to always start vim with the above created config:
|
||||
```shell
|
||||
$ vim bash/my-bash.sh
|
||||
```
|
||||
```shell
|
||||
alias vim='vim -u /etc/bashrc-devilbox.d/my-vimrc'
|
||||
```
|
||||
|
||||
The next time you open `vim` within the PHP/HHVM docker container, it will automatically source your `my-vimrc`.
|
||||
|
||||
#### 4.3 Apache / Nginx
|
||||
|
||||
##### 4.3.1 Select Httpd version
|
||||
|
@ -92,7 +92,7 @@ It will be ready in eight simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-cake
|
||||
@ -165,7 +165,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-drupal
|
||||
@ -213,7 +213,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-laravel
|
||||
@ -259,7 +259,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-phalcon
|
||||
@ -306,7 +306,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-symfony
|
||||
@ -356,7 +356,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-wp
|
||||
@ -402,7 +402,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-yii
|
||||
@ -448,7 +448,7 @@ It will be ready in six simple steps:
|
||||
|
||||
```shell
|
||||
# 1. Enter the PHP container
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
|
||||
# 2. Create a new VirtualHost directory
|
||||
devilbox@php-7.0.20 in /shared/httpd $ mkdir my-zend
|
||||
|
@ -204,7 +204,7 @@ To quickly find setup instructions for your framework of choice head over to **[
|
||||
The PHP Docker container is your workhorse which has many tools pre-installed and you can do every task inside instead of doing it on the docker host. Entering the container is done via a shipped script:
|
||||
|
||||
```shell
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
devilbox@php-7.0.19 in /shared/httpd $
|
||||
```
|
||||
|
||||
|
@ -100,10 +100,10 @@ The situation inside the container is not different from on the Docker host. All
|
||||
|
||||
#### 3.1 As devilbox user
|
||||
|
||||
In the devilbox git directory you will find a bash script called `bash.sh`. Just execute this script and it will take you directly into the PHP docker container at the project root directory.
|
||||
In the devilbox git directory you will find a bash script called `shell.sh`. Just execute this script and it will take you directly into the PHP docker container at the project root directory.
|
||||
|
||||
```shell
|
||||
host> ./bash.sh
|
||||
host> ./shell.sh
|
||||
devilbox@php-7.0.19 in /shared/httpd $
|
||||
```
|
||||
|
||||
@ -111,10 +111,11 @@ As you can see, the PS1 prompt will also show you the current configured PHP ver
|
||||
|
||||
#### 3.2 As root user
|
||||
|
||||
In case you need to perform some tasks that are only possible with root rights (such as installing or updating software), you can also use the `root_bash.sh` script.
|
||||
In case you need to perform some tasks that are only possible with root rights (such as installing or updating software), you can do so via password-less `sudo`.
|
||||
|
||||
```shell
|
||||
host> ./root_bash.sh
|
||||
host> ./shell.sh
|
||||
devilbox@php-7.0.19 in /shared/httpd $ sudo su -
|
||||
root@php-7.0.19 in /shared/httpd $
|
||||
```
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CWD="/shared/httpd"
|
||||
docker-compose exec --user root php env TERM=xterm /bin/sh -c "cd ${CWD}; exec bash -l"
|
Loading…
x
Reference in New Issue
Block a user