Skip to content

Instantly share code, notes, and snippets.

@othercodes
Created May 14, 2019 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save othercodes/f18215653499ac33cfd5866014a9445d to your computer and use it in GitHub Desktop.
Save othercodes/f18215653499ac33cfd5866014a9445d to your computer and use it in GitHub Desktop.
Migration link generator. Ubuntu
#!/usr/bin/env bash
#
# LINKLER: Migration link generator
#=========================================================
# ██╗ ██╗███╗ ██╗██╗ ██╗██╗ ███████╗██████╗
# ██║ ██║████╗ ██║██║ ██╔╝██║ ██╔════╝██╔══██╗
# ██║ ██║██╔██╗ ██║█████╔╝ ██║ █████╗ ██████╔╝
# ██║ ██║██║╚██╗██║██╔═██╗ ██║ ██╔══╝ ██╔══██╗
# ███████╗██║██║ ╚████║██║ ██╗███████╗███████╗██║ ██║
# ╚══════╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝
#=========================================================
# Prepare to be emancipated from your inferior directories
#=========================================================
#
# Execution:
# $ sudo ./linkler.sh
#
# You can also create a symlink to the /usr/bin directory
# $ sudo ln -s ~/linkler.sh /usr/bin/linkler
# $ sudo linkler
#
# RAW_MIGRATION_DIR => path to the migration repo storage
# FW_MIGRATION_DIR => path to the real migrations installation
#
RAW_MIGRATION_DIR=${RAW_MIGRATION_DIR:-/var/www/html/Migrations}
FW_MIGRATION_DIR=${FW_MIGRATION_DIR:-/var/www/importing-tool/migrations}
if [ ! -d ${RAW_MIGRATION_DIR} ]; then
echo "${RAW_MIGRATION_DIR} does not exists!"
exit 1
fi
if [ ! -d ${FW_MIGRATION_DIR} ]; then
echo "${FW_MIGRATION_DIR} does not exists!"
exit 1
fi
OPTIONS=()
for m in $(find ${RAW_MIGRATION_DIR} -maxdepth 1 -type d -print); do
if [ ${m} != ${RAW_MIGRATION_DIR} ]; then
OPTIONS+=("${m}")
OPTIONS+=("`basename ${m}`")
if [ -d "${FW_MIGRATION_DIR}/`basename ${m}`" ]; then OPTIONS+=(on); else OPTIONS+=(off); fi
fi
done
SELECTED=$(dialog --nocancel --title "Available Migrations:" --backtitle "Linkler: Prepare to be emancipated from your inferior directories." \
--checklist "Select to enable:" 40 80 20 \
"${OPTIONS[@]}" 2>&1 >/dev/tty)
clear
rm -rf ${FW_MIGRATION_DIR}/*
for m in ${SELECTED[@]}; do
ln -s "${m}/src" "${FW_MIGRATION_DIR}/`basename ${m}`"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment