Created
March 10, 2021 21:45
-
-
Save z0vsky/aa1b215817ad84401ba880793e7d1ee1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## | |
## XMind 2020 install archive creator for Kali Linux 2021.1 amd64 | |
## Date: 2021-03-10 | |
## Author: z0vsky https://github.com/z0vsky | |
## | |
## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
## http://www.wtfpl.net/about/ | |
## | |
## Usage : | |
## sudo ./create-xmind2020-offline-install-archive.sh | |
# Safety | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
# Functions | |
__log() { echo -e "[*] "${1} ; } | |
__err() { echo -e " [\033[0;31m!\033[0m] "${1} ; exit ; } | |
__warn() { echo -e " [\033[1;33m?\033[0m] "${1} ; } | |
__success() { echo -e " [\033[0;32m+\033[0m] "${1} ; } | |
# You need to be root | |
if [ "$EUID" -ne 0 ]; then | |
__err "Please run this script as root" | |
fi | |
__log "Creating temporary directory" | |
mkdir -p xmind | |
DIR=${PWD}/xmind | |
cd ${DIR} | |
__log "Backing-up Kali's sources list" | |
cp /etc/apt/sources.list ${DIR}/backup_apt_sources.list 2>/dev/null | |
if test -f "/etc/apt/preferences"; then | |
__log "Backing-up Kali's APT preferences" | |
cp /etc/apt/preferences ${DIR}/backup_apt_preferences 2>/dev/null | |
fi | |
__log "Configuring APT Preferences to fallback on Debian" | |
cat <<EOF > /etc/apt/preferences | |
Package: * | |
Pin: release o=Kali | |
Pin-Priority: 900 | |
Package: libindicator3-7 libappindicator3-1 xmind-vana | |
Pin: release o=Debian | |
Pin-Priority: -10 | |
EOF | |
echo "Temporary adding Debian sid (unstable) repository to Kali's sources" | |
grep -q "deb http://deb.debian.org/debian/ sid main" /etc/apt/sources.list || (echo "deb http://deb.debian.org/debian/ sid main" >> /etc/apt/sources.list) | |
grep -q sid /etc/apt/sources.list && __success "OK" || __err "Failed to add Debian Sid repo" | |
__log "Updating package information from sources" | |
(apt-get -qq -o Acquire::GzipIndexes=false -o APT::Sandbox::User=root update > /dev/null) && __success "OK" || __warn "There were some errors when updating packages... Continuing anyway." | |
__log "Download dependencies" | |
(apt-get -o APT::Sandbox::User=root -qq download libindicator3-7/unstable libappindicator3-1/unstable >/dev/null) && __success "OK" || __warn "There were some errors when installing dependencies... Continuing anyway." | |
mv libindicator3-7*.deb libindicator3-7.deb | |
mv libappindicator3-1*.deb libappindicator3-1.deb | |
__log "Download XMind-2020-for-Linux-amd-64bit.deb package" | |
wget -q https://www.xmind.net/zen/download/linux_deb/ -O xmind-vana.deb && __success "OK" || __err "Failed to download Xmind deb package" | |
#__log "Install Xmind from the local deb package" | |
#(apt-get install ./xmind-vana.deb -qq > /dev/null) && __success "OK" || __err "Failed to install Xmind" | |
__log "Creating offline install script to be placed in the archive" | |
cat <<EOF > install.sh | |
#!/usr/bin/env bash | |
# You need to be root | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run this script as root" | |
exit | |
fi | |
sudo apt install -qq ./libappindicator3-1.deb ./libindicator3-7.deb ./xmind-vana.deb | |
EOF | |
chmod +x install.sh | |
__log "Creating offline install archive" | |
zip -r xmind2020-offline-install.zip *.deb install.sh | |
mv xmind2020-offline-install.zip .. | |
__log Cleaning up | |
cd .. | |
rm -fr xmind | |
__log "Restoring the original sources.list" | |
mv backup_apt_sources.list /etc/apt/sources.list 2>/dev/null | |
mv backup_apt_preferences /etc/apt/preferences 2>/dev/null | |
__success "Offline install archive finished. Copy it on a system, unzip it and run sudo ./install.sh to setup XMind offline" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment