Added cURL 0 byte download check
This commit is contained in:
711
new-package.sh
711
new-package.sh
@@ -2,43 +2,43 @@
|
|||||||
# Creates a new blank OPSI package with install and remove scripts
|
# Creates a new blank OPSI package with install and remove scripts
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " $0 <product-id>"
|
echo " $0 <product-id>"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Optional parameters:"
|
echo "Optional parameters:"
|
||||||
echo " -d <Product Description> Adds a description to the package"
|
echo " -d <Product Description> Adds a description to the package"
|
||||||
echo " -n <Product Name> Adds a product name instead of autogenerating one"
|
echo " -n <Product Name> Adds a product name instead of autogenerating one"
|
||||||
echo " -g yes Adds the Gruelag prefix to package ID and name"
|
echo " -g yes Adds the Gruelag prefix to package ID and name"
|
||||||
echo " -u <Program URL> Downloads an installer file from the specified URL"
|
echo " -u <Program URL> Downloads an installer file from the specified URL"
|
||||||
echo " -i <Logo URL> Applies a logo to the package from the specified URL"
|
echo " -i <Logo URL> Applies a logo to the package from the specified URL"
|
||||||
echo " -t <Package Type> Sets the type of package to create, see below"
|
echo " -t <Package Type> Sets the type of package to create, see below"
|
||||||
echo " -v <Program version> Sets the version of the program (not the package)"
|
echo " -v <Program version> Sets the version of the program (not the package)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Package types:"
|
echo "Package types:"
|
||||||
echo " winbatch Creates a blank WinBatch package"
|
echo " winbatch Creates a blank WinBatch package"
|
||||||
echo " winbatch-inno Creates a blank INNO Installer WinBatch package"
|
echo " winbatch-inno Creates a blank INNO Installer WinBatch package"
|
||||||
echo " winbatch-nsis Creates a blank NSIS Installer WinBatch package"
|
echo " winbatch-nsis Creates a blank NSIS Installer WinBatch package"
|
||||||
echo " dosicon Creates a blank DosInAnIcon package"
|
echo " dosicon Creates a blank DosInAnIcon package"
|
||||||
echo " execps Creates a blank ExecWith Powershell package"
|
echo " execps Creates a blank ExecWith Powershell package"
|
||||||
echo " zip Creates a blank ZIP based package"
|
echo " zip Creates a blank ZIP based package"
|
||||||
echo " msi Creates a blank MSI installer package"
|
echo " msi Creates a blank MSI installer package"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Optional parameters for ZIP type package:"
|
echo "Optional parameters for ZIP type package:"
|
||||||
echo " -e <filename.exe> Specifies the launcher executable inside the ZIP file"
|
echo " -e <filename.exe> Specifies the launcher executable inside the ZIP file"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" = "" ]]; then
|
if [[ "$1" = "" ]]; then
|
||||||
echo "Please specify the package name as first parameter."
|
echo "Please specify the package name as first parameter."
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
productId="$1"
|
productId="$1"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
@@ -48,27 +48,27 @@ pkgType="default"
|
|||||||
# Read command flags
|
# Read command flags
|
||||||
while getopts ":d:g:n:t:e:u:i:v:" flag
|
while getopts ":d:g:n:t:e:u:i:v:" flag
|
||||||
do
|
do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
d) productDescription="${OPTARG}";;
|
d) productDescription="${OPTARG}";;
|
||||||
g) productIdPrefix="gruelag-" && productNamePrefix="Gruelag ";;
|
g) productIdPrefix="gruelag-" && productNamePrefix="Gruelag ";;
|
||||||
n) productName=${OPTARG};;
|
n) productName=${OPTARG};;
|
||||||
t) pkgType=${OPTARG};;
|
t) pkgType=${OPTARG};;
|
||||||
e) zipExecutable="${OPTARG}";;
|
e) zipExecutable="${OPTARG}";;
|
||||||
u) downloadUrl="${OPTARG}";;
|
u) downloadUrl="${OPTARG}";;
|
||||||
i) imageUrl="${OPTARG}";;
|
i) imageUrl="${OPTARG}";;
|
||||||
v) programVersion="${OPTARG}";;
|
v) programVersion="${OPTARG}";;
|
||||||
*)
|
*)
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
productId="${productIdPrefix}${productId}"
|
productId="${productIdPrefix}${productId}"
|
||||||
|
|
||||||
# Generate product name from ID if it's not set
|
# Generate product name from ID if it's not set
|
||||||
if [ "${productName}" = "" ]; then
|
if [ "${productName}" = "" ]; then
|
||||||
productName=$(echo "${productId//-/ }" | sed -r 's/\<./\U&/g')
|
productName=$(echo "${productId//-/ }" | sed -r 's/\<./\U&/g')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "-- Package data --"
|
echo "-- Package data --"
|
||||||
@@ -80,11 +80,11 @@ echo ""
|
|||||||
|
|
||||||
echo "Creating package directory..."
|
echo "Creating package directory..."
|
||||||
if [ -d "${productId}" ]; then
|
if [ -d "${productId}" ]; then
|
||||||
echo "A folder with the package name already exists"
|
echo "A folder with the package name already exists"
|
||||||
exit 1
|
exit 1
|
||||||
elif ! mkdir "${productId}"; then
|
elif ! mkdir "${productId}"; then
|
||||||
echo "Could not create the package directory"
|
echo "Could not create the package directory"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
pushd "${productId}" >/dev/null
|
pushd "${productId}" >/dev/null
|
||||||
|
|
||||||
@@ -103,25 +103,25 @@ uninstallScript: remove.ins
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ ! "${downloadUrl}" = "" ]; then
|
if [ ! "${downloadUrl}" = "" ]; then
|
||||||
echo "Downloading program file..."
|
echo "Downloading program file..."
|
||||||
|
|
||||||
mkdir data
|
mkdir data
|
||||||
pushd data >/dev/null
|
pushd data >/dev/null
|
||||||
|
|
||||||
_filename=$(curl -f -s -w "%{filename_effective}" -L -O "${downloadUrl}")
|
_filename=$(curl -f -s -w "%{filename_effective}" -L -O "${downloadUrl}")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Curl did not manage to download the file from ${downloadUrl}"
|
echo "Curl did not manage to download the file from ${downloadUrl}"
|
||||||
else
|
else
|
||||||
bytes=$(wc -c "${_filename}" | awk '{ print $1 }')
|
bytes=$(wc -c "${_filename}" | awk '{ print $1 }')
|
||||||
if [ ${bytes} -le 1 ]; then
|
if [ ${bytes} -le 1 ]; then
|
||||||
echo "Program file was downloaded, but is ${bytes} bytes in size!"
|
echo "Program file was downloaded, but is ${bytes} bytes in size!"
|
||||||
else
|
else
|
||||||
echo "Program file downloaded to data/${_filename}, ${bytes} length"
|
echo "Program file downloaded to data/${_filename}, ${bytes} length"
|
||||||
filename="${_filename}"
|
filename="${_filename}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## START Some reusable code snippets as variables:
|
## START Some reusable code snippets as variables:
|
||||||
@@ -153,380 +153,379 @@ EOS
|
|||||||
echo "Creating install and remove script files for type ${pkgType}..."
|
echo "Creating install and remove script files for type ${pkgType}..."
|
||||||
case "${pkgType}" in
|
case "${pkgType}" in
|
||||||
winbatch-nsis)
|
winbatch-nsis)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instFile="setup.exe"
|
_instFile="setup.exe"
|
||||||
else
|
else
|
||||||
_instFile="${filename}"
|
_instFile="${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Install
|
WinBatch_Install
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Install]
|
[WinBatch_Install]
|
||||||
"%ScriptPath%\\data\\${_instFile}" /S
|
"%ScriptPath%\\data\\${_instFile}" /S
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
DefVar \$InstallPath\$
|
DefVar \$InstallPath\$
|
||||||
DefVar \$UninsFile\$
|
DefVar \$UninsFile\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
Sub_SetVars
|
Sub_SetVars
|
||||||
Files_CopyUninstallerToTemp
|
Files_CopyUninstallerToTemp
|
||||||
WinBatch_Uninstall
|
WinBatch_Uninstall
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
Files_RemoveTempUninstaller
|
Files_RemoveTempUninstaller
|
||||||
|
|
||||||
[Sub_SetVars]
|
[Sub_SetVars]
|
||||||
Set \$InstallPath\$ = "%ProgramFilesDir%\\${productName}"
|
Set \$InstallPath\$ = "%ProgramFilesDir%\\${productName}"
|
||||||
Set \$UninsFile\$ = "unins000.exe"
|
Set \$UninsFile\$ = "unins000.exe"
|
||||||
|
|
||||||
[Files_CopyUninstallerToTemp]
|
[Files_CopyUninstallerToTemp]
|
||||||
Copy "\$InstallPath\$\\\$UninsFile\$" "%opsiTmpDir%"
|
Copy "\$InstallPath\$\\\$UninsFile\$" "%opsiTmpDir%"
|
||||||
|
|
||||||
[WinBatch_Uninstall]
|
[WinBatch_Uninstall]
|
||||||
"%opsiTmpDir%\\\$UninsFile\$" /S _?=\$InstallPath\$
|
"%opsiTmpDir%\\\$UninsFile\$" /S _?=\$InstallPath\$
|
||||||
|
|
||||||
[Files_RemoveTempUninstaller]
|
[Files_RemoveTempUninstaller]
|
||||||
Delete "%opsiTmpDir%\\\$UninsFile\$"
|
Delete "%opsiTmpDir%\\\$UninsFile\$"
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Remember to change the path and uninstaller file name in remove.ins!"
|
echo "Remember to change the path and uninstaller file name in remove.ins!"
|
||||||
;;
|
;;
|
||||||
winbatch-inno)
|
winbatch-inno)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instFile="setup.exe"
|
_instFile="setup.exe"
|
||||||
else
|
else
|
||||||
_instFile="${filename}"
|
_instFile="${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Install
|
WinBatch_Install
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Install]
|
[WinBatch_Install]
|
||||||
"%ScriptPath%\\data\\${_instFile}" /SILENT /NOCANCEL /NORESTART /FORCECLOSEAPPLICATIONS /NORESTARTAPPLICATIONS
|
"%ScriptPath%\\data\\${_instFile}" /SILENT /NOCANCEL /NORESTART /FORCECLOSEAPPLICATIONS /NORESTARTAPPLICATIONS
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
DefVar \$UninstallPath\$
|
DefVar \$UninstallPath\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Uninstall
|
WinBatch_Uninstall
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Uninstall]
|
[WinBatch_Uninstall]
|
||||||
"%ProgramFilesDir%\\${productName}\\unins000.exe" /SILENT
|
"%ProgramFilesDir%\\${productName}\\unins000.exe" /SILENT
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Remember to change the uninstaller path in remove.ins!"
|
echo "Remember to change the uninstaller path in remove.ins!"
|
||||||
;;
|
;;
|
||||||
winbatch)
|
winbatch)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instFile="setup.exe"
|
_instFile="setup.exe"
|
||||||
else
|
else
|
||||||
_instFile="${filename}"
|
_instFile="${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Install
|
WinBatch_Install
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Install]
|
[WinBatch_Install]
|
||||||
"%ScriptPath%\\data\\${_instFile}" /S
|
"%ScriptPath%\\data\\${_instFile}" /S
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Remove
|
WinBatch_Remove
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Remove]
|
[WinBatch_Remove]
|
||||||
"uninstall-exe-path-here" /S
|
"uninstall-exe-path-here" /S
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Remember to customize the executable paths in install.ins and remove.ins!"
|
echo "Remember to customize the executable paths in install.ins and remove.ins!"
|
||||||
;;
|
;;
|
||||||
dosicon)
|
dosicon)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instCommand="your-setup-command-here"
|
_instCommand="your-setup-command-here"
|
||||||
else
|
else
|
||||||
_instCommand="%ScriptPath%\\data\\${filename}"
|
_instCommand="%ScriptPath%\\data\\${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Install
|
WinBatch_Install
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[DosInAnIcon_Install]
|
[DosInAnIcon_Install]
|
||||||
@echo off
|
@echo off
|
||||||
${_instCommand}
|
${_instCommand}
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
DosInAnIcon_Remove
|
DosInAnIcon_Remove
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[DosInAnIcon_Remove]
|
[DosInAnIcon_Remove]
|
||||||
@echo off
|
@echo off
|
||||||
your-uninstall-command-here
|
your-uninstall-command-here
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Remember to customize the DosInAnIcon commands in install.ins and remove.ins!"
|
echo "Remember to customize the DosInAnIcon commands in install.ins and remove.ins!"
|
||||||
;;
|
;;
|
||||||
execps)
|
execps)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instCommand="your-setup-command-here"
|
_instCommand="your-setup-command-here"
|
||||||
else
|
else
|
||||||
_instCommand="%ScriptPath%\\data\\${filename}"
|
_instCommand="%ScriptPath%\\data\\${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
ExecWith_Install "powershell.exe" -ExecutionPolicy Bypass
|
ExecWith_Install "powershell.exe" -ExecutionPolicy Bypass
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[ExecWith_Install]
|
[ExecWith_Install]
|
||||||
trap { "PS Error: \$_"; exit 1 }
|
trap { "PS Error: \$_"; exit 1 }
|
||||||
${_instCommand}
|
${_instCommand}
|
||||||
if(-not (\$?)) { exit 1 }
|
if(-not (\$?)) { exit 1 }
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
ExecWith_Remove "powershell.exe" -ExecutionPolicy Bypass
|
ExecWith_Remove "powershell.exe" -ExecutionPolicy Bypass
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[ExecWith_Remove]
|
[ExecWith_Remove]
|
||||||
trap { "PS Error: $_"; exit 1 }
|
trap { "PS Error: $_"; exit 1 }
|
||||||
your-uninstall-command-here
|
your-uninstall-command-here
|
||||||
if(-not (\$?)) { exit 1 }
|
if(-not (\$?)) { exit 1 }
|
||||||
|
|
||||||
${Sub_HandleExitCode}
|
${Sub_HandleExitCode}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Remember to customize the PowerShell commands in install.ins and remove.ins!"
|
echo "Remember to customize the PowerShell commands in install.ins and remove.ins!"
|
||||||
;;
|
;;
|
||||||
zip)
|
zip)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_zipFile="${productId}.zip"
|
_zipFile="${productId}.zip"
|
||||||
else
|
else
|
||||||
_zipFile="${filename}"
|
_zipFile="${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${zipExecutable}" = "" ]; then
|
if [ "${zipExecutable}" = "" ]; then
|
||||||
_zipExe="start.exe"
|
_zipExe="start.exe"
|
||||||
else
|
else
|
||||||
_zipExec="${zipExecutable}"
|
_zipExec="${zipExecutable}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
Sub "%ScriptPath%\\remove.inc.ins"
|
Sub "%ScriptPath%\\remove.inc.ins"
|
||||||
Files_UnzipPackage
|
Files_UnzipPackage
|
||||||
LinkFolder_StartMenuEntry
|
LinkFolder_StartMenuEntry
|
||||||
|
|
||||||
[Files_UnzipPackage]
|
[Files_UnzipPackage]
|
||||||
CheckTargetPath = "%ProgramFilesDir%\\${productId}"
|
CheckTargetPath = "%ProgramFilesDir%\\${productId}"
|
||||||
UnzipFile "%ScriptPath%\\data\\${_zipFile}" "%ProgramFilesDir%\\${productId}"
|
UnzipFile "%ScriptPath%\\data\\${_zipFile}" "%ProgramFilesDir%\\${productId}"
|
||||||
|
|
||||||
[LinkFolder_StartMenuEntry]
|
[LinkFolder_StartMenuEntry]
|
||||||
Set_BaseFolder Common_Programs
|
Set_BaseFolder Common_Programs
|
||||||
Set_SubFolder "${productName}"
|
Set_SubFolder "${productName}"
|
||||||
Set_Link
|
Set_Link
|
||||||
name: ${productName}
|
name: ${productName}
|
||||||
target: "%ProgramFilesDir%\\${productId}\\${_zipExe}"
|
target: "%ProgramFilesDir%\\${productId}\\${_zipExe}"
|
||||||
parameters:
|
parameters:
|
||||||
working_dir: "%ProgramFilesDir%\\${productId}"
|
working_dir: "%ProgramFilesDir%\\${productId}"
|
||||||
icon_file: "%ProgramFilesDir%\\${productId}\\${_zipExe}"
|
icon_file: "%ProgramFilesDir%\\${productId}\\${_zipExe}"
|
||||||
icon_index: 0
|
icon_index: 0
|
||||||
shortcut:
|
shortcut:
|
||||||
End_Link
|
End_Link
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
Sub "%ScriptPath%\remove.inc.ins"
|
Sub "%ScriptPath%\remove.inc.ins"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.inc.ins <<-EOF
|
cat >remove.inc.ins <<-EOF
|
||||||
Files_RemoveProgramFolder
|
Files_RemoveProgramFolder
|
||||||
LinkFolder_RemoveStartMenuEntry
|
LinkFolder_RemoveStartMenuEntry
|
||||||
|
|
||||||
[Files_RemoveProgramFolder]
|
[Files_RemoveProgramFolder]
|
||||||
Del -sf "%ProgramFilesDir%\\${productId}"
|
Del -sf "%ProgramFilesDir%\\${productId}"
|
||||||
|
|
||||||
[LinkFolder_RemoveStartMenuEntry]
|
[LinkFolder_RemoveStartMenuEntry]
|
||||||
Set_BaseFolder Common_Programs
|
Set_BaseFolder Common_Programs
|
||||||
Delete_Subfolder "${productName}"
|
Delete_Subfolder "${productName}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Make sure the names and paths in install.ins and remove.inc.ins are correct!"
|
echo "Make sure the names and paths in install.ins and remove.inc.ins are correct!"
|
||||||
;;
|
;;
|
||||||
msi)
|
msi)
|
||||||
if [ "${filename}" = "" ]; then
|
if [ "${filename}" = "" ]; then
|
||||||
_instFile="setup.msi"
|
_instFile="setup.msi"
|
||||||
else
|
else
|
||||||
_instFile="${filename}"
|
_instFile="${filename}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Install
|
WinBatch_Install
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Install]
|
[WinBatch_Install]
|
||||||
msiexec /passive /i "%ScriptPath%\\data\\${_instFile}"
|
msiexec /passive /i "%ScriptPath%\\data\\${_instFile}"
|
||||||
|
|
||||||
${Sub_HandleExitCode_MSI}
|
${Sub_HandleExitCode_MSI}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
DefVar \$ExitCode\$
|
DefVar \$ExitCode\$
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
WinBatch_Remove
|
WinBatch_Remove
|
||||||
Sub_HandleExitCode
|
Sub_HandleExitCode
|
||||||
|
|
||||||
[WinBatch_Remove]
|
[WinBatch_Remove]
|
||||||
"%ScriptDrive%\\tools\\autoit\\msiRemove_withLog.exe" "${productName}"
|
"%ScriptDrive%\\tools\\autoit\\msiRemove_withLog.exe" "${productName}"
|
||||||
|
|
||||||
${Sub_HandleExitCode_MSI}
|
${Sub_HandleExitCode_MSI}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Make sure the WinBatch_Remove section in remove.ins does the right things!"
|
echo "Make sure the WinBatch_Remove section in remove.ins does the right things!"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
cat >install.ins <<-EOF
|
cat >install.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Installiere ${productName}...
|
Message=Installiere ${productName}...
|
||||||
DefVar \$ExitCode\$
|
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
Sub_Install
|
Sub_Install
|
||||||
|
|
||||||
[Sub_Install]
|
[Sub_Install]
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >remove.ins <<-EOF
|
cat >remove.ins <<-EOF
|
||||||
[Initial]
|
[Initial]
|
||||||
Message=Entferne ${productName}...
|
Message=Entferne ${productName}...
|
||||||
|
|
||||||
[Actions]
|
[Actions]
|
||||||
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
ShowBitmap "%ScriptPath%\\logo.png" "${productName}"
|
||||||
Sub_Remove
|
Sub_Remove
|
||||||
|
|
||||||
[Sub_Remove]
|
[Sub_Remove]
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create logo if specified
|
# Create logo if specified
|
||||||
if [ ! "${imageUrl}" = "" ]; then
|
if [ ! "${imageUrl}" = "" ]; then
|
||||||
_imgfilename="$(curl -s -w "%{filename_effective}" -O "${imageUrl}")"
|
_imgfilename="$(curl -s -w "%{filename_effective}" -O "${imageUrl}")"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Couldn't fetch the specified image URL to build the logo!"
|
echo "Couldn't fetch the specified image URL to build the logo!"
|
||||||
else
|
else
|
||||||
if ! convert "${_imgfilename}" -resize 160x160 ../logo-overlay-small.png -gravity SouthEast -geometry +3+3 -composite logo.png; then
|
if ! convert "${_imgfilename}" -resize 160x160 ../logo-overlay-small.png -gravity SouthEast -geometry +3+3 -composite logo.png; then
|
||||||
echo "Couldn't convert the specified URL to logo.png, maybe it's not an image?"
|
echo "Couldn't convert the specified URL to logo.png, maybe it's not an image?"
|
||||||
else
|
else
|
||||||
echo "Logo successfully generated"
|
echo "Logo successfully generated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "${_imgfilename}"
|
rm "${_imgfilename}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Copying placeholder logo to package, consider replacing it"
|
echo "Copying placeholder logo to package, consider replacing it"
|
||||||
cp ../logo-placeholder.png logo.png
|
cp ../logo-placeholder.png logo.png
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user