Skip to content

Commit

Permalink
Greatly Improved Efficiency On Loader, Updated Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
maxexcloo committed May 6, 2013
1 parent 758a72c commit fda12bc
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 136 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Expand Up @@ -5,8 +5,8 @@ the Free Software Foundation, either version 3 of the License, or

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
13 changes: 7 additions & 6 deletions README.md
Expand Up @@ -3,7 +3,7 @@ Notes

Run on a freshly installed server under root, may not work under an already setup server!

No warranty.
No warranty. Limited support available (although I will try my best to make your experience with the script a good one!)

Compatibility
=============
Expand All @@ -26,20 +26,21 @@ Compatibility
+ VMware
+ vServer (Debian Only)
+ Xen HVM
+ Xen PV (WIP)

Instructions
============

This script contains several modules designed to help you set up your server how you want it. Simply run the below download command then run "bash minstall.sh help" or "bash minstall.sh modules" to see help or modules respectively.
This script contains several modules designed to help you set up your server how you want it. Simply run the download command below to install to your server.

**Download Minstall**

To download Minstall to your home directory (it's recommended that you download and run as root) use the following command:
To download Minstall run the following command under root:

wget --no-check-certificate -O minstall.tar.gz http://www.github.com/KnightSwarm/Minstall/archive/master.tar.gz; tar zxvf minstall.tar.gz; rm minstall.tar.gz; cd Minstall-*
wget -O /opt/minstall.tar.gz --no-check-certificate http://www.github.com/KnightSwarm/Minstall/archive/master.tar.gz; mkdir /opt/minstall/; tar --directory=/opt/minstall/ --file=/opt/minstall.tar.gz --strip-components=1 -v -x -z; mv /opt/minstall/extra/launcher.sh /usr/bin/minstall

**Remove Minstall**

To remove the Minstall script run the following command under the same user you installed Minstall under:
To remove the Minstall script run the following command under root:

cd ~; rm -rf minstall
rm -rf /opt/minstall/ /usr/bin/minstall
3 changes: 0 additions & 3 deletions extra/config.ini
Expand Up @@ -9,9 +9,6 @@
; Debug Mode
; This flag pauses the script after each module has been run and enables easier viewing of output. To enable set value to 1, to disable set to 0.
debug=0
; Enabled Modules
; Defines the list of enabled modules to be run. Order is taken into account and each module must be separed by a comma with no spaces.
modules=""
; Automatic Package List Update
; This flag will enable updating of the system package list prior to the first module running. To enable set value to 1, to disable set to 0.
package_update=1
4 changes: 4 additions & 0 deletions extra/launcher.sh
@@ -0,0 +1,4 @@
#!/bin/bash
# Launch Minstall
cd /opt/minstall
bash minstall.sh "$@"
214 changes: 90 additions & 124 deletions minstall.sh
@@ -1,5 +1,5 @@
#!/bin/bash
# Script Initialisation Functions
# Script Loader

# Load Variables
source config.sh
Expand All @@ -21,32 +21,73 @@ for file in $LIBRARYPATH/*.sh; do
done

#####################
## Default Actions ##
## Parse Arguments ##
#####################

# Print Help If No Parameters Are Specified
if [ $# = 0 ]; then
# Load Module Listing Script
source $MODULEPATH/help-modules.sh
# Check Arguments
while getopts ":c:m:su" option; do
# Argument List
case $option in
# Config File
c)
# Check Config File Existance
if [ -f $OPTARG ]; then
# Print Warning
warning "Loaded Custom Config File \"$OPTARG\"."

# Set Config File Variable
CONFIGFILE=$OPTARG
# Error Condition
else
# Print Error
error "Custom Config File \"$OPTARG\" does not exist."

# Exit
exit
fi
;;
# Module List
m)
# Set Module List Variable
MODULELIST=$OPTARG,
;;
# Setup Mode
s)
# Print Warning
warning "Setup Mode Running..."

# Exit
exit
fi
# Set Setup Variable State
SETUP=1
;;
# Unattended Mode
u)
# Print Warning
warning "Unattended Mode Running..."

# Check For Unattended Mode
if [ $1 = "-u" ]; then
# Enable Unattended Mode
UNATTENDED=1
else
# Disable Unattended Mode
UNATTENDED=0
fi
# Enable Unattended Mode
UNATTENDED=1
;;
# No Arguments
\?)
# Load Module Listing Script
source $MODULEPATH/help-modules.sh

# Read Configuration
read_ini $CONFIGFILE
# Exit
exit
;;
# Invalid Argument
:)
# Print Error
error "Option -$OPTARG requires an argument."

# Exit
exit
;;
esac
done

# Check For Setup Mode
if [ $1 = "-s" ]; then
# Setup Mode
if [ $SETUP = 1 ]; then
# Create Base Configuration File
cp extra/config.ini $CONFIGFILE

Expand All @@ -63,114 +104,39 @@ if [ $1 = "-s" ]; then
exit
fi

###########
## Modes ##
###########

# Attended Mode
if [ $UNATTENDED = 0 ]; then
# Check Parameters Against Options
case $1 in
# Help Function
help)
# Load Help Script
source $MODULEPATH/help/init.sh

# Exit
exit
;;
# Module List Function
modules)
# Load Module Listing Script
source $MODULEPATH/help-modules/init.sh

# Exit
exit
;;
# Load Modules
*)
# Define Modules
MODULELIST=$1,

# Loop Through Modules
while echo $MODULELIST | grep -q \,; do
# Define Current Module
MODULE=${MODULELIST%%\,*}

# Remove Current Module From List
MODULELIST=${MODULELIST#*\,}

# Check If Module Exists
if [ -f $MODULEPATH/$MODULE/init.sh ]; then
# Print Module Description
header $(describe $MODULEPATH/$MODULE/init.sh)

# Load Module
source $MODULEPATH/$MODULE/init.sh
# Module Doesn't Exist
else
# Ask If User Wants To Abort
if question --default no "Module $MODULE not found. Do you want to abort? (y/N)"; then
# Print Message
error "Aborted Module!"

# Exit Script
exit
fi
fi

# Debug Pause
if [ $(read_var minstall__debug) = 1 ]; then
# Wait For User Input
read -p "Press any key to continue..."
fi
done
;;
esac
fi

# Unattended Mode
if [ $UNATTENDED = 1 ]; then
# Define Modules
MODULELIST=$(read_var minstall__modules),

# Loop Through Modules
while echo $MODULELIST | grep -q \,; do
# Define Current Module
MODULE=${MODULELIST%%\,*}

# Remove Current Module From List
MODULELIST=${MODULELIST#*\,}

# Check If Array Empty
if [ $MODULE = 0 ]; then
# Print Message
error "No modules in modules array. Aborting."

# Exit Script
exit
fi

# Check If Module Exists
if [ -f $MODULEPATH/$MODULE/init.sh ]; then
# Print Module Description
header $(describe $MODULEPATH/$MODULE/init.sh)
# Read Configuration
read_ini $CONFIGFILE

# Load Module
source $MODULEPATH/$MODULE/init.sh
# Module Doesn't Exist
else
# Execute Modules
while echo $MODULELIST | grep -q \,; do
# Define Module
MODULE=${MODULELIST%%\,*}

# Remove Current Module From Module List
MODULELIST=${MODULELIST#*\,}

# Check If Module Exists
if [ -f $MODULEPATH/$MODULE/init.sh ]; then
# Print Module Description
header $(describe $MODULEPATH/$MODULE/init.sh)

# Load Module
source $MODULEPATH/$MODULE/init.sh
# Error Condition
else
# Ask If User Wants To Abort
if question --default no "Module $MODULE not found. Do you want to abort? (y/N)" || [ $UNATTENDED = 1 ]; then
# Print Message
error "Module $MODULE not found. Aborting."

# Exit Script
exit
fi
fi

# Debug Pause
if [ $(read_var minstall__debug) = 1 ]; then
# Wait For User Input
read -p "Press any key to continue..."
fi
done
fi
# Debug Pause
if [ $(read_var minstall__debug) = 1 ]; then
# Wait For User Input
read -p "Press any key to continue..."
fi
done
2 changes: 1 addition & 1 deletion modules/configure-http-nginx/init.sh
Expand Up @@ -54,7 +54,7 @@ if question --default no "Do you want to protect the default host by denying unm
# Disable Default Host Protection
else
# Default Host Reset
if question --default no "Do you want to reset the default host to the script default (this will override your default virtual host if you have assigned one)? (y/N)" || [ $(read_var_module default_host_reset) = 1 ]; then
if question --default no "Do you want to reset the default host to the script default (this will override your default virtual host if you have assigned one)? (y/N)" || [ $(read_var_module default_host_reset) = 1 ]; then
subheader "Resetting Default Host..."
cp $MODULEPATH/install-http-nginx/etc/hosts.d/default.conf /etc/nginx/hosts.d/
fi
Expand Down

0 comments on commit fda12bc

Please sign in to comment.