Browse Source

Updated installer to support piped script as source

pull/553/head
Jared Ballou 10 years ago
parent
commit
63ffb0087b
  1. 32
      functions/install_lgsm.sh

32
functions/install_lgsm.sh

@ -2,30 +2,39 @@
# LGSM install_lgsm function # LGSM install_lgsm function
# Author: Jared Ballou # Author: Jared Ballou
# Website: http://gameservermanagers.com # Website: http://gameservermanagers.com
lgsm_version="200116" lgsm_version="300116"
# Description: Display menu of available games and install the one selected # Description: Display menu of available games and install the one selected
# Perform installation # Perform installation
fn_runfunction menu.sh fn_runfunction menu.sh
# Listing of available games # Listing of available games
gamelist="gamedata/__game_list" gamelist="gamedata/__game_list"
# Installation path # Installation path
installpath=$(cd ~ && pwd) installpath=$(cd ~ && pwd)
# Get game list # Get game list
fn_getgithubfile $gamelist fn_getgithubfile $gamelist
# Display installer menu # Display installer menu
fn_menu result "Linux Game Server Manager" "Select game to install" "${lgsmdir}/${gamelist}" fn_menu result "Linux Game Server Manager" "Select game to install" "${lgsmdir}/${gamelist}"
echo $result
# If we have a selection, do the install # If we have a selection, do the install
if [ -n "${result}" ]; then if [ -n "${result}" ]; then
# Confirm path for installation if [ "${BASH_SOURCE[0]}" == "" ]; then
read -p "Select path to install ${result} [${installpath}]: " input scriptpath="${installpath}/${result}"
installpath=${input:-$installpath} else
scriptpath="${installpath}/${result}" # Confirm path for installation
# If file exists, confirm overwrite read -p "Select path to install ${result} [${installpath}]: " input
if [ -e "${scriptpath}" ]; then installpath=${input:-$installpath}
read -p "WARNING! ${scriptpath} already exists! OVERWRITE!? [y/N]: " input scriptpath="${installpath}/${result}"
if [ "${input}" != "y" ] && [ "${input}" != "Y" ]; then exit; fi # If file exists, confirm overwrite
if [ -e "${scriptpath}" ]; then
read -p "WARNING! ${scriptpath} already exists! OVERWRITE!? [y/N]: " input
if [ "${input}" != "y" ] && [ "${input}" != "Y" ]; then exit; fi
fi
fi fi
# Install script # Install script
echo -ne "Installing to ${scriptpath}... \c" echo -ne "Installing to ${scriptpath}... \c"
@ -34,11 +43,12 @@ if [ -n "${result}" ]; then
mkdir -p $(dirname "${scriptpath}") mkdir -p $(dirname "${scriptpath}")
fi fi
# Copy script and set executable # Copy script and set executable
cp "${0}" "${scriptpath}" fn_getgithubfile "${scriptpath}" noexec "${core_script}"
chmod 0755 "${scriptpath}" chmod 0755 "${scriptpath}"
if [ $? ]; then if [ $? ]; then
fn_colortext green "Done" fn_colortext green "Done"
echo "Script deployed to ${scriptpath}" echo "Script deployed! To install game, run:"
echo "${scriptpath} install"
else else
fn_colortext red "FAIL" fn_colortext red "FAIL"
fi fi

Loading…
Cancel
Save