#!/bin/bash # This is a shell script to add the parts required to create a # FreePBX image to run on the WARP to a check out of the unmodified # version of pads. It will do all the work to add the code required, # patch the code, set up the config file. Once the script is run, # you will be able to just run make like in any other build of PADS. # # Note that this script must be run in the root of a checked out # version of pads # # Declare variables we need BASE_DIR=`pwd` PACKAGE_DIR="$BASE_DIR/package" FREEPBX_PACKAGE_DIR="$BASE_DIR/../packages" RUN_ONCE_TEST="$BASE_DIR/.preprocessed" # Should only run this script once, check if we have already if [[ ( -f $RUN_ONCE_TEST ) ]]; then echo "preprocess script already been run, exit success and keep going" exit 0 fi # Do a simple check we are in the base of a pads checkout if [[ ( ! -d ./package ) && ( ! -d ./bin ) && ( ! -d ./utils ) && ( ! -d ./config ) && ( ! -f Makefile ) ]]; then echo "preprocess script cannot detect being in base of a PADS checkout" echo "Do you want to try and continue (y/n)" read choice if [ $choice == "n" ]; then echo "Exiting. Please rerun script in the base of a PADS folder" exit 0 fi fi # Let's move the code we need to modify PADS for FreePBX if # it has not already been done, check for freepbx package moved cd $BASE_DIR if [[ ( ! -d $PACKAGE_DIR/freepbx ) ]]; then # Copy packages into PADS directory echo "Copying the FreePBX packages" cp -r $FREEPBX_PACKAGE_DIR/* $PACKAGE_DIR fi # # let's set package build list defaults # cd $PACKAGE_DIR # Turn off packages we need to in the standard PADS echo "Turn off packages we need to in the standard PADS" sed -i "s|default y|default n|" $PACKAGE_DIR/asterisk-gui/Config.in sed -i "s|default y|default n|" $PACKAGE_DIR/httpd/Config.in # Turn on packages we need to in the standard PADS sed -i "s|default n|default y|" $PACKAGE_DIR/zoneinfo/Config.in sed -i "s|default n|default y|" $PACKAGE_DIR/sqlite/Config.in # Update the base Makefile to increase inodes sed -i "s|-i 2048 |-i 2520 |" $BASE_DIR/Makefile # Patch the code we need to cd $PACKAGE_DIR echo "Patch the default packages we need to for FreePBX." patch -p1 < patches/Config.in.patch sed -i "s|source \"package/extra_packages/Config.in|#source \"package/extra_packages/Config.in|" $PACKAGE_DIR/Config.in patch -p1 < patches/skeleton/skeleton.patch cp patches/skeleton/rc.local.freepbx skeleton/etc/ patch -p1 < patches/busybox.patch patch -p1 < patches/sqlite.patch patch -p1 < patches/libxml.patch patch -p1 < patches/tftpd.patch patch -p1 < patches/chan_pika.mk.patch patch -p1 < patches/asterisk.mk.patch sed -i "s|TARGET_DIR)/var|PERSISTENT1_STORAGE)/var|" $PACKAGE_DIR/asterisk/asterisk.mk sed -i "s|PERSISTENT_STORAGE)/var|PERSISTENT1_STORAGE)/var|" $PACKAGE_DIR/asterisk/asterisk.mk # Replace the code we have to in the stock checkout. echo "Replace the default packages we need to for FreePBX." rm -rf $PACKAGE_DIR/autoflash/* cp -r $PACKAGE_DIR/patches/autoflash/* $PACKAGE_DIR/autoflash/ rm -rf $PACKAGE_DIR/php/* cp -r $PACKAGE_DIR/patches/php/* $PACKAGE_DIR/php/ # Should only run this script once, mark that we have already touch $RUN_ONCE_TEST echo "" echo "Standard PADS has been patched to build" echo "a FreePBX enabled set of WARP images." echo ""