Browse Source

Fixies & cleanup

pull/4186/head
FliesWithWind 2 years ago
parent
commit
00baf3e711
  1. 2
      lgsm/config-default/config-lgsm/arma3server/_default.cfg
  2. 149
      lgsm/functions/command_workshop_install.sh
  3. 135
      lgsm/functions/command_workshop_update.sh
  4. 329
      lgsm/functions/workshop_core.sh

2
lgsm/config-default/config-lgsm/arma3server/_default.cfg

@ -30,7 +30,7 @@ servermods=""
## Mods to be downloaded from Steam Workshop ## Mods to be downloaded from Steam Workshop
# Use workshop ids # Use workshop ids
# workshopmods="450814997;2131302796" # workshopmods="450814997;2131302796"
workshopmods="450814997;2131302796" workshopmods=""
## Path to BattlEye ## Path to BattlEye
# Leave empty for default # Leave empty for default

149
lgsm/functions/command_workshop_install.sh

@ -14,124 +14,33 @@ check.sh
workshop_core.sh workshop_core.sh
fn_print_header fn_print_header
fn_create_workshop_dir
fn_workshop_download "450814997" fn_workshop_get_list
# # Displays a list of installed mods. # Displays a list of installed mods.
# fn_mods_installed_list
# if [ "${installedmodscount}" -gt "0" ]; then echo -e ""
# echo -e "Installed addons/mods" echo -e "Installed workshop addons/mods"
# echo -e "=================================" echo -e "================================="
# # Go through all available commands, get details and display them to the user. fn_workshop_installed_list
# for ((llindex = 0; llindex < ${#installedmodslist[@]}; llindex++)); do
# # Current mod is the "llindex" value of the array we're going through. for modid in "${workshoplist[@]}"; do
# currentmod="${installedmodslist[llindex]}" # Check if the mod is already installed and warn the user.
# fn_mod_get_info # if ! fn_workshop_check_mod_update $modid; then
# # Display mod info to the user. # fn_print_warning_nl "$(fn_workshop_get_mod_name ${modid}) is already installed"
# echo -e " * ${green}${modcommand}${default}${default}" # fn_script_log_warn "$(fn_workshop_get_mod_name ${modid}) is already installed"
# done # echo -e " * Any configs may be overwritten."
# echo -e "" # if ! fn_prompt_yn "Continue?" Y; then
# fi # core_exit.sh
# fi
# echo -e "Available addons/mods" # fn_script_log_info "User selected to continue"
# echo -e "=================================" # fi
# # Display available mods from mods_list.sh. echo -e ""
# # Set and reset vars echo -e "Installing $(fn_workshop_get_mod_name ${modid})."
# compatiblemodslistindex=0 echo -e "================================="
# # As long as we're within index values. fn_workshop_download $modid
# while [ "${compatiblemodslistindex}" -lt "${#compatiblemodslist[@]}" ]; do fn_workshop_copy_destination $modid
# # Set values for convenience. done
# displayedmodname="${compatiblemodslist[compatiblemodslistindex]}"
# displayedmodcommand="${compatiblemodslist[compatiblemodslistindex + 1]}" fn_workshop_lowercase
# displayedmodsite="${compatiblemodslist[compatiblemodslistindex + 2]}"
# displayedmoddescription="${compatiblemodslist[compatiblemodslistindex + 3]}"
# # Output mods to the user.
# echo -e "${displayedmodname} - ${displayedmoddescription} - ${displayedmodsite}"
# echo -e " * ${cyan}${displayedmodcommand}${default}"
# # Increment index from the amount of values we just displayed.
# let "compatiblemodslistindex+=4"
# ((totalmodsavailable++))
# done
# # If no mods are available for a specific game.
# if [ -z "${compatiblemodslist}" ]; then
# fn_print_fail_nl "No mods are currently available for ${gamename}."
# fn_script_log_info "No mods are currently available for ${gamename}."
# core_exit.sh
# fi
# fn_script_log_info "${totalmodsavailable} addons/mods are available for install"
# ## User selects a mod.
# echo -e ""
# while [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; do
# echo -en "Enter an ${cyan}addon/mod${default} to ${green}install${default} (or exit to abort): "
# read -r usermodselect
# # Exit if user says exit or abort.
# if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then
# core_exit.sh
# # Supplementary output upon invalid user input.
# elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
# fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
# fi
# done
# # Get mod info.
# currentmod="${usermodselect}"
# fn_mod_get_info
# echo -e ""
# echo -e "Installing ${modprettyname}"
# echo -e "================================="
# fn_script_log_info "${modprettyname} selected for install"
# # Check if the mod is already installed and warn the user.
# if [ -f "${modsinstalledlistfullpath}" ]; then
# if [ "$(sed -n "/^${modcommand}$/p" "${modsinstalledlistfullpath}")" ]; then
# fn_print_warning_nl "${modprettyname} is already installed"
# fn_script_log_warn "${modprettyname} is already installed"
# echo -e " * Any configs may be overwritten."
# if ! fn_prompt_yn "Continue?" Y; then
# core_exit.sh
# fi
# fn_script_log_info "User selected to continue"
# fi
# fi
# ## Installation.
# # If amxmodx check if metamod exists first
# if [ "${modcommand}" == "amxmodx" ]; then
# fn_mod_exist "metamod"
# fi
# if [ "${modcommand}" == "amxmodxcs" ] \
# || [ "${modcommand}" == "amxmodxdod" ] \
# || [ "${modcommand}" == "amxmodxtfc" ] \
# || [ "${modcommand}" == "amxmodxns" ] \
# || [ "${modcommand}" == "amxmodxts" ]; then
# fn_mod_exist "amxmodx"
# fi
# fn_create_mods_dir
# fn_mods_clear_tmp_dir
# fn_mods_create_tmp_dir
# fn_mod_install_files
# fn_mod_lowercase
# fn_mod_create_filelist
# fn_mod_copy_destination
# fn_mod_add_list
# fn_mod_tidy_files_list
# fn_mods_clear_tmp_dir
# # Create/modify existing liblist.gam file for Metamod
# if [ "${modcommand}" == "metamod" ]; then
# fn_mod_install_liblist_gam_file
# fi
# # Create/modify plugins.ini file for Metamod
# if [ "${modcommand}" == "amxmodx" ]; then
# fn_mod_install_amxmodx_file
# fi
# echo -e "${modprettyname} installed"
# fn_script_log_pass "${modprettyname} installed."
core_exit.sh core_exit.sh

135
lgsm/functions/command_workshop_update.sh

@ -12,138 +12,25 @@ fn_firstcommand_set
check.sh check.sh
workshop_core.sh workshop_core.sh
fn_print_header fn_print_header
fn_create_workshop_dir
fn_workshop_get_list fn_workshop_get_list
# Displays a list of installed mods.
echo -e "Installed workshop addons/mods"
echo -e "================================="
fn_workshop_installed_list
for modid in "${workshoplist[@]}"; do for modid in "${workshoplist[@]}"; do
modname="$(fn_workshop_get_mod_name $modid)" modname="$(fn_workshop_get_mod_name $modid)"
if fn_workshop_check_mod_update $modid; then if fn_workshop_check_mod_update $modid; then
echo "Mod ${modname} is not up to date." echo "Mod ${modname} (${modid}) is not up to date."
fn_workshop_download $modid fn_workshop_download $modid
else fn_workshop_copy_destination $modid
else
echo "Mod $modname is up to date." echo "Mod $modname is up to date."
fi fi
done done
#fn_workshop_download "450814997" fn_workshop_lowercase
# # Displays a list of installed mods.
# fn_mods_installed_list
# if [ "${installedmodscount}" -gt "0" ]; then
# echo -e "Installed addons/mods"
# echo -e "================================="
# # Go through all available commands, get details and display them to the user.
# for ((llindex = 0; llindex < ${#installedmodslist[@]}; llindex++)); do
# # Current mod is the "llindex" value of the array we're going through.
# currentmod="${installedmodslist[llindex]}"
# fn_mod_get_info
# # Display mod info to the user.
# echo -e " * ${green}${modcommand}${default}${default}"
# done
# echo -e ""
# fi
# echo -e "Available addons/mods"
# echo -e "================================="
# # Display available mods from mods_list.sh.
# # Set and reset vars
# compatiblemodslistindex=0
# # As long as we're within index values.
# while [ "${compatiblemodslistindex}" -lt "${#compatiblemodslist[@]}" ]; do
# # Set values for convenience.
# displayedmodname="${compatiblemodslist[compatiblemodslistindex]}"
# displayedmodcommand="${compatiblemodslist[compatiblemodslistindex + 1]}"
# displayedmodsite="${compatiblemodslist[compatiblemodslistindex + 2]}"
# displayedmoddescription="${compatiblemodslist[compatiblemodslistindex + 3]}"
# # Output mods to the user.
# echo -e "${displayedmodname} - ${displayedmoddescription} - ${displayedmodsite}"
# echo -e " * ${cyan}${displayedmodcommand}${default}"
# # Increment index from the amount of values we just displayed.
# let "compatiblemodslistindex+=4"
# ((totalmodsavailable++))
# done
# # If no mods are available for a specific game.
# if [ -z "${compatiblemodslist}" ]; then
# fn_print_fail_nl "No mods are currently available for ${gamename}."
# fn_script_log_info "No mods are currently available for ${gamename}."
# core_exit.sh
# fi
# fn_script_log_info "${totalmodsavailable} addons/mods are available for install"
# ## User selects a mod.
# echo -e ""
# while [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; do
# echo -en "Enter an ${cyan}addon/mod${default} to ${green}install${default} (or exit to abort): "
# read -r usermodselect
# # Exit if user says exit or abort.
# if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then
# core_exit.sh
# # Supplementary output upon invalid user input.
# elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
# fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
# fi
# done
# # Get mod info.
# currentmod="${usermodselect}"
# fn_mod_get_info
# echo -e ""
# echo -e "Installing ${modprettyname}"
# echo -e "================================="
# fn_script_log_info "${modprettyname} selected for install"
# # Check if the mod is already installed and warn the user.
# if [ -f "${modsinstalledlistfullpath}" ]; then
# if [ "$(sed -n "/^${modcommand}$/p" "${modsinstalledlistfullpath}")" ]; then
# fn_print_warning_nl "${modprettyname} is already installed"
# fn_script_log_warn "${modprettyname} is already installed"
# echo -e " * Any configs may be overwritten."
# if ! fn_prompt_yn "Continue?" Y; then
# core_exit.sh
# fi
# fn_script_log_info "User selected to continue"
# fi
# fi
# ## Installation.
# # If amxmodx check if metamod exists first
# if [ "${modcommand}" == "amxmodx" ]; then
# fn_mod_exist "metamod"
# fi
# if [ "${modcommand}" == "amxmodxcs" ] \
# || [ "${modcommand}" == "amxmodxdod" ] \
# || [ "${modcommand}" == "amxmodxtfc" ] \
# || [ "${modcommand}" == "amxmodxns" ] \
# || [ "${modcommand}" == "amxmodxts" ]; then
# fn_mod_exist "amxmodx"
# fi
# fn_create_mods_dir
# fn_mods_clear_tmp_dir
# fn_mods_create_tmp_dir
# fn_mod_install_files
# fn_mod_lowercase
# fn_mod_create_filelist
# fn_mod_copy_destination
# fn_mod_add_list
# fn_mod_tidy_files_list
# fn_mods_clear_tmp_dir
# # Create/modify existing liblist.gam file for Metamod
# if [ "${modcommand}" == "metamod" ]; then
# fn_mod_install_liblist_gam_file
# fi
# # Create/modify plugins.ini file for Metamod
# if [ "${modcommand}" == "amxmodx" ]; then
# fn_mod_install_amxmodx_file
# fi
# echo -e "${modprettyname} installed"
# fn_script_log_pass "${modprettyname} installed."
core_exit.sh core_exit.sh

329
lgsm/functions/workshop_core.sh

@ -9,7 +9,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
# Files and Directories. # Files and Directories.
steam="${steamcmd}/steam" steam="${steamcmd}/steam"
workhshopmodsdir="${serverfiles}/mods" workshopmodsdir="${serverfiles}/mods"
keysdir="${serverfiles}/keys" keysdir="${serverfiles}/keys"
workshopmodsdldir="${lgsmdir}/workshop" workshopmodsdldir="${lgsmdir}/workshop"
workshopmodslist="workshop-mods.txt" workshopmodslist="workshop-mods.txt"
@ -101,15 +101,6 @@ fn_workshop_download() {
core_exit.sh core_exit.sh
fi fi
done done
# if [ -f "${workshopmodsrcdir}/meta.cpp" ]; then
# echo "Mod $modid downloaded"
# modsrcdirs[$modid]="$modsrcdir"
# return 0
# else
# echo "Mod $modid was not successfully downloaded"
# return 1
# fi
} }
fn_workshop_get_list() { fn_workshop_get_list() {
@ -118,12 +109,22 @@ fn_workshop_get_list() {
fn_workshop_get_latest_mod_version() { fn_workshop_get_latest_mod_version() {
local modid="$1" local modid="$1"
local serverresp="$(curl -s -d "itemcount=1&publishedfileids[0]=${modid}" "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1")" local serverresp="$(curl -s -d "itemcount=1&publishedfileids[0]=${modid}" "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1")"
local remupd= local remupd=
if [[ "$serverresp" =~ \"hcontent_file\":[[:space:]]*([^,]*) ]]; then if [[ "$serverresp" =~ \"hcontent_file\":[[:space:]]*([^,]*) ]]; then
remupd="${BASH_REMATCH[1]}" remupd="${BASH_REMATCH[1]}"
fi fi
echo "$remupd" | tr -d '"' echo "$remupd" | tr -d '"'
}
fn_workshop_get_name_from_steam() {
local modid="$1"
local serverresp="$(curl -s -d "itemcount=1&publishedfileids[0]=${modid}" "http://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1")"
local title=
if [[ "$serverresp" =~ \"title\":[[:space:]]*([^,]*) ]]; then
title="${BASH_REMATCH[1]}"
fi
echo "$title" | tr -d '"'
} }
fn_workshop_check_mod_update() { fn_workshop_check_mod_update() {
@ -141,8 +142,8 @@ fn_workshop_check_mod_update() {
fn_workshop_is_mod_copy_needed(){ fn_workshop_is_mod_copy_needed(){
local modid="$1" local modid="$1"
local modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}" local modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}"
if [ ! -f "${workhshopmodsdir}/${modid}/meta.cpp" ]; then return 0; fi if [ ! -f "${workshopmodsdir}/${modid}/meta.cpp" ]; then return 0; fi
local instmft="$(grep "timestamp" ${workhshopmodsdir}/${modid}/meta.cpp)" local instmft="$(grep "timestamp" ${workshopmodsdir}/${modid}/meta.cpp)"
if [ -z "$instmft" ]; then return 0; fi if [ -z "$instmft" ]; then return 0; fi
local remmft="$(grep "timestamp" $modsrc/meta.cpp)" local remmft="$(grep "timestamp" $modsrc/meta.cpp)"
if [[ -n "${remmft}" && "${instmft}" != "${remmft}" ]]; then if [[ -n "${remmft}" && "${instmft}" != "${remmft}" ]]; then
@ -154,123 +155,118 @@ fn_workshop_is_mod_copy_needed(){
fn_workshop_get_mod_name(){ fn_workshop_get_mod_name(){
local modid="$1" local modid="$1"
#echo "$(grep -Po '(?<=name = ").+?(?=")' ${workshopmodsdir}/steamapps/workshop/content/${gameappid}/${modid}/mod.cpp)" if ! [ -d "${workshopmodsdir}/${modid}" ]; then
echo "$(grep -Po '(?<=name = ").+?(?=")' ${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}/mod.cpp)" echo "$(grep -Po '(?<=name = ").+?(?=")' ${workshopmodsdir}/${modid}/mod.cpp)"
elif ! [ -d "${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}" ]; then
echo "$(grep -Po '(?<=name = ").+?(?=")' ${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/${modid}/mod.cpp)"
else
echo "$(fn_workshop_get_name_from_steam ${modid})"
fi
} }
# Convert workshop mod files to lowercase if needed. # Convert workshop mod files to lowercase if needed.
fn_workshop_lowercase() { fn_workshop_lowercase() {
local modid="$1" # local modid="$1"
# local modname="$(fn_workshop_get_mod_name $modid)"
# Arma 3 requires lowercase # Arma 3 requires lowercase
if [ "${engine}" == "realvirtuality" ]; then if [ "${engine}" == "realvirtuality" ]; then
echo -en "converting ${modprettyname} files to lowercase..." echo -en "Converting ${modname} files to lowercase..."
fn_sleep_time fn_sleep_time
fn_script_log_info "Converting ${modprettyname} files to lowercase" fn_script_log_info "Converting ${modname} files to lowercase"
# Total files and directories for the mod, to output to the user # Total files and directories for the mod, to output to the user
fileswc=$(find "${extractdir}" | wc -l) fileswc=$(find "${workshopmodsdir}" | wc -l)
# Total uppercase files and directories for the mod, to output to the user # Total uppercase files and directories for the mod, to output to the user
filesupperwc=$(find "${extractdir}" -name '*[[:upper:]]*' | wc -l) filesupperwc=$(find "${workshopmodsdir}/" -name '*[[:upper:]]*' | wc -l)
fn_script_log_info "Found ${filesupperwc} uppercase files out of ${fileswc}, converting" fn_script_log_info "Found ${filesupperwc} uppercase files out of ${fileswc}, converting"
echo -en "Found ${filesupperwc} uppercase files out of ${fileswc}, converting..." echo -en "Found ${filesupperwc} uppercase files out of ${fileswc}, converting..."
# Works but not on folders
# while IFS= read -r -d '' file; do
# mv -b -- "$file" "${file,,}" 2>/dev/null
# done < <(find ${workshopmodsdir} -depth -name '*[A-Z]*' -print0)
# while IFS= read -r -d '' file; do
# mv -b -- "$file" "${file,,}" 2>/dev/null
# done < <(find ${workshopmodsdir}/ -depth -name '*[A-Z]*' -print0)
# Works bu not on WSL?
# https://unix.stackexchange.com/questions/20222/change-entire-directory-tree-to-lower-case-names/20232#20232
#
find ${workshopmodsdir} -depth -exec sh -c '
t=${0%/*}/$(printf %s "${0##*/}" | tr "[:upper:]" "[:lower:]");
[ "$t" = "$0" ] || mv -i "$0" "$t"
' {} \;
#
# Coudln't get this to work.
#
# Convert files and directories starting from the deepest to prevent issues (-depth argument) # Convert files and directories starting from the deepest to prevent issues (-depth argument)
while read -r src; do # while IFS= read -r -d '' src; do
# We have to convert only the last file from the path, otherwise we will fail to convert anything if a parent dir has any uppercase # # We have to convert only the last file from the path, otherwise we will fail to convert anything if a parent dir has any uppercase
# therefore, we have to separate the end of the filename to only lowercase it rather than the whole line # # therefore, we have to separate the end of the filename to only lowercase it rather than the whole line
# Gather parent dir, filename lowercase filename, and set lowercase destination name # # Gather parent dir, filename lowercase filename, and set lowercase destination name
latestparentdir=$(dirname "${src}") # latestparentdir=$(dirname "${src}")
latestfilelc=$(basename "${src}" | tr '[:upper:]' '[:lower:]') # latestfilelc=$(basename "${src}" | tr '[:upper:]' '[:lower:]')
dst="${latestparentdir}/${latestfilelc}" # dst="${latestparentdir}/${latestfilelc}"
# Only convert if destination does not already exist for some reason # # Only convert if destination does not already exist for some reason
if [ ! -e "${dst}" ]; then # if [ ! -e "${dst}" ]; then
# Finally we can rename the file # # Finally we can rename the file
mv "${src}" "${dst}" # mv "${src}" "${dst}"
# Exit if it fails for any reason # # Exit if it fails for any reason
local exitcode=$? # local exitcode=$?
if [ "${exitcode}" != 0 ]; then # if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl # fn_print_fail_eol_nl
core_exit.sh # core_exit.sh
fi # fi
fi # fi
done < <(find "${extractdir}" -depth -name '*[[:upper:]]*') # done < <(find "${workshopmodsdir}" -depth -name '*[[:upper:]]*' -print0)
fn_print_ok_eol_nl fn_print_ok_eol_nl
fi fi
} }
# # Copy the mod into serverfiles. # # Copy the mod into serverfiles.
# fn_mod_copy_destination() { fn_workshop_copy_destination() {
# echo -en "copying ${modprettyname} to ${modinstalldir}..." local modid="$1"
# fn_sleep_time local modname="$(fn_workshop_get_mod_name $modid)"
# cp -Rf "${extractdir}/." "${modinstalldir}/" if fn_workshop_is_mod_copy_needed $modid; then
# local exitcode=$? echo "Copying mod ${modname} (${modid})"
# if [ "${exitcode}" != 0 ]; then # If workshop mod exists in installation folder, delete it for clean install
# fn_print_fail_eol_nl if [ -d "${workshopmodsdir}/${modid}" ]; then
# fn_script_log_fatal "Copying ${modprettyname} to ${modinstalldir}" rm -rf "${workshopmodsdir}/${modid}"
# else fi
# fn_print_ok_eol_nl modsrc="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/$modid"
# fn_script_log_pass "Copying ${modprettyname} to ${modinstalldir}" cp -fa ${modsrc} ${workshopmodsdir}
# fi if [ "${engine}" == "realvirtuality" ]; then
# } modkey="${workshopmodsdldir}/steamapps/workshop/content/${gameappid}/$modid/keys"
if ! [ -d "${modkey}" ]; then
# ## Information Gathering. modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/Keys"
fi
# # Get details of a mod any (relevant and unique, such as full mod name or install command) value. if ! [ -d "${modkey}" ]; then
# fn_mod_get_info() { modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/key"
# # Variable to know when job is done. fi
# modinfocommand="0" if ! [ -d "${modkey}" ]; then
# # Find entry in global array. modkey="$steamcmd/steamapps/workshop/content/${gameappid}/$modid/Key"
# for ((index = 0; index <= ${#mods_global_array[@]}; index++)); do fi
# # When entry is found. if ! [ -d "${modkey}" ]; then
# if [ "${mods_global_array[index]}" == "${currentmod}" ]; then echo "Mod ${modname} seems to be missing key folder. Tring to copy key from the main folder."
# # Go back to the previous "MOD" separator. cp -fa "${workshopmodsdir}/${modid}/*.bikey" ${keysdir}
# for ((index = index; index <= ${#mods_global_array[@]}; index--)); do else
# # When "MOD" is found. cp -fa $modkey/*.bikey ${keysdir}
# if [ "${mods_global_array[index]}" == "MOD" ]; then fi
# # Get info. fi
# fn_mods_define else
# modinfocommand="1" echo "Mod ${modname} is already in mods folder."
# break fi
# fi # echo -en "copying ${modprettyname} to ${modinstalldir}..."
# done # fn_sleep_time
# fi # cp -Rf "${extractdir}/." "${modinstalldir}/"
# # Exit the loop if job is done. # local exitcode=$?
# if [ "${modinfocommand}" == "1" ]; then # if [ "${exitcode}" != 0 ]; then
# break # fn_print_fail_eol_nl
# fi # fn_script_log_fatal "Copying ${modprettyname} to ${modinstalldir}"
# done # else
# fn_print_ok_eol_nl
# # What happens if mod is not found. # fn_script_log_pass "Copying ${modprettyname} to ${modinstalldir}"
# if [ "${modinfocommand}" == "0" ]; then # fi
# fn_script_log_error "Could not find information for ${currentmod}" }
# fn_print_error_nl "Could not find information for ${currentmod}"
# core_exit.sh
# fi
# }
# # Builds list of installed mods.
# # using installed-mods.txt grabing mod info from mods_list.sh.
# fn_mods_installed_list() {
# fn_mods_count_installed
# # Set/reset variables.
# installedmodsline="1"
# installedmodslist=()
# modprettynamemaxlength="0"
# modsitemaxlength="0"
# moddescriptionmaxlength="0"
# modcommandmaxlength="0"
# # Loop through every line of the installed mods list ${modsinstalledlistfullpath}.
# while [ "${installedmodsline}" -le "${installedmodscount}" ]; do
# currentmod=$(sed "${installedmodsline}q;d" "${modsinstalledlistfullpath}")
# # Get mod info to make sure mod exists.
# fn_mod_get_info
# # Add the mod to available commands.
# installedmodslist+=("${modcommand}")
# # Increment line check.
# ((installedmodsline++))
# done
# if [ "${installedmodscount}" ]; then
# fn_script_log_info "${installedmodscount} addons/mods are currently installed"
# fi
# }
# ## Directory management. # ## Directory management.
@ -291,66 +287,27 @@ fn_create_workshop_dir() {
fi fi
fi fi
# Create mod install directory. # Create mod install directory.
if [ ! -d "${workhshopmodsdir}" ]; then if [ ! -d "${workshopmodsdir}" ]; then
echo -en "creating Steam Workshop install directory ${workhshopmodsdir}..." echo -en "creating Steam Workshop install directory ${workshopmodsdir}..."
mkdir -p "${workhshopmodsdir}" mkdir -p "${workshopmodsdir}"
exitcode=$? exitcode=$?
if [ "${exitcode}" != 0 ]; then if [ "${exitcode}" != 0 ]; then
fn_print_fail_eol_nl fn_print_fail_eol_nl
fn_script_log_fatal "Creating mod install directory ${workhshopmodsdir}" fn_script_log_fatal "Creating mod install directory ${workshopmodsdir}"
core_exit.sh core_exit.sh
else else
fn_print_ok_eol_nl fn_print_ok_eol_nl
fn_script_log_pass "Creating mod install directory ${workhshopmodsdir}" fn_script_log_pass "Creating mod install directory ${workshopmodsdir}"
fi fi
fi fi
} }
# # Create tmp download mod directory.
# fn_mods_create_tmp_dir() {
# if [ ! -d "${modstmpdir}" ]; then
# mkdir -p "${modstmpdir}"
# exitcode=$?
# echo -en "creating mod download directory ${modstmpdir}..."
# if [ "${exitcode}" != 0 ]; then
# fn_print_fail_eol_nl
# fn_script_log_fatal "Creating mod download directory ${modstmpdir}"
# core_exit.sh
# else
# fn_print_ok_eol_nl
# fn_script_log_pass "Creating mod download directory ${modstmpdir}"
# fi
# fi
# }
# # Remove the tmp mod download directory when finished.
# fn_mods_clear_tmp_dir() {
# if [ -d "${modstmpdir}" ]; then
# echo -en "clearing mod download directory ${modstmpdir}..."
# rm -fr "${modstmpdir:?}"
# exitcode=$?
# if [ "${exitcode}" != 0 ]; then
# fn_print_fail_eol_nl
# fn_script_log_fatal "Clearing mod download directory ${modstmpdir}"
# core_exit.sh
# else
# fn_print_ok_eol_nl
# fn_script_log_pass "Clearing mod download directory ${modstmpdir}"
# fi
# fi
# # Clear temp file list as well.
# if [ -f "${modsdir}/.removedfiles.tmp" ]; then
# rm -f "${modsdir:?}/.removedfiles.tmp"
# fi
# }
# Counts how many mods were installed. # Counts how many mods were installed.
fn_workshop_count_installed() { fn_workshop_count_installed() {
if [ -f "${workhshopmodsdir}" ]; then if [ -f "${workshopmodsdir}" ]; then
installedmodscount=$(ls -l "${workhshopmodsdir}" | grep -c ^d) installedworkshopmodscount=$(ls -l "${workshopmodsdir}" | grep -c ^d)
else else
installedmodscount=0 installedworkshopmodscount=0
fi fi
} }
@ -359,7 +316,7 @@ fn_workshop_check_installed() {
# Count installed mods. # Count installed mods.
fn_workshop_count_installed fn_workshop_count_installed
# If no mods are found. # If no mods are found.
if [ ${installedmodscount} -eq 0 ]; then if [ ${installedworkshopmodscount}/* -eq 0 ]; then
echo -e "" echo -e ""
fn_print_failure_nl "No installed workshop mods or addons were found" fn_print_failure_nl "No installed workshop mods or addons were found"
echo -e " * Install mods using LinuxGSM first with: ./${selfname} workshop-install" echo -e " * Install mods using LinuxGSM first with: ./${selfname} workshop-install"
@ -368,31 +325,15 @@ fn_workshop_check_installed() {
fi fi
} }
# fn_mod_exist() { # Builds list of installed Steam Workshop mods.
# modreq=$1 fn_workshop_installed_list() {
# # requires one parameter, the mod fn_workshop_count_installed
# if [ -f "${modsdir}/${modreq}-files.txt" ]; then for f in ${workshopmodsdir}/*; do
# # how many lines is the file list if [ -d "$f" ]; then
# modsfilelistsize=$(wc -l < "${modsdir}/${modreq}-files.txt") echo -e "$(fn_workshop_get_mod_name $(basename ${f})) ($(basename ${f}))"
# # if file list is empty fi
# if [ "${modsfilelistsize}" -eq 0 ]; then done
# fn_mod_required_fail_exist "${modreq}" if [ "${installedworkshopmodscount}" ]; then
# fi fn_script_log_info "${installedworkshopmodscount} addons/mods are currently installed"
# else fi
# fn_mod_required_fail_exist "${modreq}" }
# fi
# }
# fn_mod_required_fail_exist() {
# modreq=$1
# # requires one parameter, the mod
# fn_script_log_fatal "${modreq}-files.txt is empty: unable to find ${modreq} installed"
# echo -en "* Unable to find '${modreq}' which is required prior to installing this mod..."
# fn_print_fail_eol_nl
# core_exit.sh
# }
# ## Database initialisation.
# mods_list.sh
# fn_mods_available

Loading…
Cancel
Save