Extending Webby

What makes you think you need to extend webby? Well maybe you need to install Apache2 version between 2.4.0 ~ 2.4.28. You can write your own bash script and then put it on ext/ folder of webby. Webby only preserve software listed on script by choosing the latest version of each software releases. So you will not be able to use webby to install all release of each software, because each software version will require spesific library release used by the software on the date of its release.
For example Apache 2.0 release will not compatible with openssl 1.1.1, because the openssl libraries used by apache 2.0 will use openssl at the time apache 2.0 was built; so regarding to the release date of apache 2.0 it will compatible with openssl 0.9.x.

When you write your own bash script, you need to test individually each of library version that match to the software release. If you're a linux C++ expert you can solve those compiling errors of each libraries by your self, but if you're a newbie of C++ programming than google is your answer. Ok enough talk, now we need to guide you to write your first webby extension. Webby will call your script using the main function "_ext_main", so this is the template of your first script :

#!/bin/bash
function _ext_main
{
    # Your bash code here
    echo "Hello World, I will guide you installing my own web server"
}

Ok, so you can save it as a bash script on ext/webserver-1.0.sh

To call from webby you just need to execute this :
    sudo webby -q webserver-1.0

Thats it, from now on you can start to write your own webby extension. For a complete example you can see the Apache-2.4.25.sh inside ext folder.
As a guide you can use these following internal webby functions to use in your script.

Function Description
add_dialog
This function will help you to print your install dialog procedure, to easing your life rather than write same code again each time you need a new features. There are 2 modes of dialog, first is Confirmation dialog, and second is Option list dialog.

Parameter of Confirmation Dialog :
1. Message/Question
2. Dialog type :
    Dialog type is like a confirmation dialog on windows :
    $DIALOG_YESNO : This will print confirmation with Yes as a default answer if you fill nothing.
    $DIALOG_NOYES : This will print confirmation with No as a default answer if you fill nothing.
3. Dialog Result : This will contain the answer of a user.

Example :
   message="Are you want to format your HDrive ?"
   add_dialog $message $DIALOG_YESNO result
   echo "You pick : $result"

The above example will print

root@localhost$ Are you want to format your HDrive ? [Y/n] :

Parameter of Option List Dialog :
1. Message/Question
2. Title
3. Dialog Type :
    $DIALOG_OPTS : This will print a list of options from your own defined function to give a list of
                                    choices in an array, your own function must give 1 parameter as a result array.
4. User Defined Function name : This is the name of your own function located at your own script.
5. Dialog Result : This will contain the answer of a user.
check_base_pkg
This function will check your system each of base package needed for source code compilation tools.
Ubuntu or Debian based will check for "build-essential gcc g++ libtool m4 autoconf automake make unzip"
Centos or RHEL based will check for "rpm-build gcc gcc-c++ libtool"
compile_mysql This function will help you install mysql server or mariadb server
Parameter :
1. server name : 'mysql' or 'mariadb'
2. version

Mysql server version you can use :  '5.5.59' '5.6.39' '5.7.21'
Mariadb server version you can use :  '5.5.59' '10.0.34' '10.1.32' '10.2.14' '10.3.5'

Example :
compile_mysql mysql 5.5.59
compile_pgsql This function will help you install postgresql server
Parameter :
1. version

Postgresql server version you can use : '8.04'
define_pkgconfig This function will detect your correct pkgconfig version based on your OS type and version.
Return value : pkg-config version number

Example :
define_pkgconfig your_var_name
wget -O ~/pkgconfig-0.${your_var_name}.tar.gz   https://pkg-config.freedesktop.org/releases/pkg-config-0.${your_var_name}.tar.gz

The example above will help you to define which pkgconfig version does your OS needed. You can use your own version for your own choice without this function, but this function will help you to pick the file version that match to your OS release date.
define_cmake This function will determine your correct cmake version based on your OS type and version.
Return value : cmake version number
define_gpgerror This function will help you determine gpgerror file version based on your OS release.
define_gcrypt This function will help you determine gcrypt file version based on your OS release.
define_gnutls This function will help you determine gnutls file version based on your OS release.
define_glib This function will help you determine glib file version based on your OS release.
download
This function will help you to download file from the internet.
Parameter :
1. URL
2. Folder/Filename

Example :
download   https://pkg-config.freedesktop.org/releases/pkg-config-0.23.tar.gz   /home/user/pkgconfig.tar.gz
download_packages This function will help you download software packages with its dependency libraries.
Parameter :
1. Software name
   {apache2, nginx, lighttpd, openlitespeed, hiawata, cherokee, monkey, mysql, postgresql, mongodb, firebird, php}
2. Software version

Example :
download_packages mysql 5.5.59
in_array
This function will check if spesific word exists on array

Example :
declare -a my_list=('one' 'two' 'three')
in_array my_list "four" && echo "Yes its there" || echo "No its not there"
prepare_install_media This function will help you to setup your apt-get (Debian based) or yum (RHEL based) to set your cd/dvd OS installation as your main repository. This function will help you to setup apt-cdrom / yum cd based repo for old version of the OS release. If you have installed a latest OS version so you don't need this function because you still can use apt-get / yum using online repository.
require This function will automatically download, extract, and install of common libraries needed by Apache2, nginx, lighttpd. But this function will not guarantee you of successfull compilation, it will compile with default parameter used by webby. If you experience compilation error than you need to write it manually to add some patch to the source. Array index will determine the dependency of each other, you can see the dependency of each libraries here

Example Use :
declare -a files=("apr-1.6.2" "apr-util-1.6.0")
require files

The command above will install apr-1.6.0 dependency used by apr-util-1.6.0 (--with-apr)

Wrong use :
declare -a files=("apr-util-1.6.0" "apr-1.6.2")
require files

The command above will install apr-util-1.6.0 without apr-1.6.2

These list is the name of library you can use for your own script.
zlib, bzip2, libiconv, pcre, openssl, libressl, pkg-config, glib, expat, apr, apr-util, libgpg-error, libgcrypt, gnutls
update_wget This function will update your current wget tool to version 1.17.1. Wget 1.17.1 will help you to get file from https://github.com or https://curl.haxx.se without SSL error.
verify_packages
This function will help you to verify local source file with online version. This function will compare sha1, sha256, or gpgkey file signatures from local with online source. This will also help you to detect any updates of each software source codes, if file signature changed then you need to re-test the new version from website, is there any bugs with current webby script ?

Parameter :
1. Software name
   {apache2, nginx, lighttpd, openlitespeed, hiawata, cherokee, monkey, mysql, postgresql, mongodb, firebird, php}
2. Software version

Example :
verify_packages apache2 2.4.25

You can also use these following constant variable

Constant Description
OSVER
Contain operating system version
PWD
Current active directory
INSTALL_DIR
Webby installation directory
ARCHIVE_DIR
Source code download folder
DEPLOY_DIR
Source code deployment folder
SSH_KEY Location of ssh-keygen
SSH_CP Location of ssh-copy-id
SHARUTILS_EXISTS If uuencode & uudecode is installed on your system than it will contain the path, if not it will empty
WGET_BIN Location of wget
WGET_VERSION Contain wget software version
TEMP_DIR Location of temporary dir /tmp
SCRIPT_NAME
Contain the filename of webby script
MAJORVERSION | OSMAJ Contain operating system major version
MINORVERSION | OSMIN Contain operating system minor version
CPU Contain CPU type of x32 or x64
MEMSIZE Contain total memory of your system
OSNAME Contain the name of your operating system (ubuntu, debian, fedora, centos, readhat)
USRADD Contain location of useradd, function to add new user on system
GRPADD Contain location of groupadd, function to add new group on system
USERDEL Contain location of userdel, function to delete user on system
GRPDEL
Contain location of groupdel, function to delete group on system
VERSION Contain operating system version
DEFAULT_PKG Contain package management system (apt, yum, dnf)
DEFAULT_SHELL Contain location of nologin, default user fcgi shell (nologin)
TZ Contain active time zone of current system
UPDATE_WGET Contain 1 (true) or 0 (false) if your system needs wget update
UNINSTALL_ALL Flag from script parameter to uninstall
webby -u all
UNINSTALL_HTTP_ONLY Flag from script parameter to uninstall web server only
webby -u skipdb
UNINSTALL_HTTP_AND_FTP Flag from script parameter to uninstall web server and ftp server
webby -u skipdata



[ Index ] [ Extend ]