appimage: Add cli parameter for specifying the package version

This commit is contained in:
Mike Salvatore 2021-04-29 13:22:04 -04:00
parent 68759e3970
commit 8cb47ce3e7
3 changed files with 23 additions and 3 deletions

View File

@ -20,7 +20,7 @@ remove build artifacts by removing the following files and directories.
- $HOME/.monkey_island (optional) - $HOME/.monkey_island (optional)
- $HOME/appimage/squashfs-root - $HOME/appimage/squashfs-root
- $HOME/git/monkey - $HOME/git/monkey
- $HOME/appimage/Infection_Monkey-x86_64.AppImage - $HOME/appimage/Infection_Monkey*x86_64.AppImage
After removing the above files and directories, you can again execute `bash After removing the above files and directories, you can again execute `bash
build_appimage.sh`. build_appimage.sh`.

View File

@ -220,6 +220,11 @@ add_apprun() {
build_appimage() { build_appimage() {
log_message "Building AppImage" log_message "Building AppImage"
ARCH="x86_64" appimagetool "$APPDIR" ARCH="x86_64" appimagetool "$APPDIR"
apply_version_to_appimage "$1"
}
apply_version_to_appimage() {
mv "Infection_Monkey-x86_64.AppImage" "Infection_Monkey-$1-x86_64.AppImage"
} }
if is_root; then if is_root; then
@ -233,6 +238,21 @@ Run \`sudo -v\`, enter your password, and then re-run this script."
exit 1 exit 1
fi fi
monkey_version="dev"
while (( "$#" )); do
case "$1" in
--version)
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
monkey_version=$2
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
esac
done
install_build_prereqs install_build_prereqs
install_appimage_tool install_appimage_tool
@ -241,7 +261,7 @@ clone_monkey_repo "$@"
setup_appdir setup_appdir
build_appimage build_appimage "$monkey_version"
log_message "Deployment script finished." log_message "Deployment script finished."
exit 0 exit 0

View File

@ -6,4 +6,4 @@
rm -rf "$HOME/.monkey_island" rm -rf "$HOME/.monkey_island"
rm -rf "$HOME/appimage/squashfs-root" rm -rf "$HOME/appimage/squashfs-root"
rm -rf "$HOME/git/monkey" rm -rf "$HOME/git/monkey"
rm "$HOME/appimage/Infection_Monkey-x86_64.AppImage" rm $HOME/appimage/Infection_Monkey*x86_64.AppImage