Created
May 7, 2016 15:20
-
-
Save libcrack/d6a4926584e70a995eb542ad6b345ea8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| # sáb abr 9 18:57:00 CEST 2016 | |
| NFS="${NFS:-/mnt/nfs/${USER}}" | |
| nfs_mnt="/mnt/nfs/${USER}" | |
| linked_dirs="(ls ${HOME})" | |
| X="\e[0m" | |
| R="\e[0;31m" | |
| G="\e[0;32m" | |
| delete_user_links(){ | |
| cd "${HOME}" | |
| for dir in *; do | |
| if [ -h "${dir}" ]; then | |
| printf "${G}${dir} -> "$(readlink -m "${dir}")"${X}\n" | |
| fi | |
| done | |
| cd "${OLDPWD}" | |
| } | |
| create_user_links(){ | |
| cd "${HOME}" | |
| for dir in ${linked_dirs[@]}; do | |
| if [ ! -e "${HOME}/${dir}" ]; then | |
| printf "${G}${dir} -> ${nfs_mnt}/${dir}${X}" | |
| ln -s "${nfs_mnt}/${dir}" "${dir}" | |
| fi | |
| done | |
| cd "${OLDPWD}" | |
| } | |
| show_help(){ | |
| printf " | |
| Usage: $0 ${R}-h|-c|-d${X}\n | |
| ${R}-h|--help${X}: show help | |
| ${R}-c|--create${X}: create user links | |
| ${R}-d|--delete${X}: delete user links\n\n" | |
| } | |
| case $1 in | |
| -d|--delete) delete_user_links ;; | |
| -c|--create) create_user_links ;; | |
| -h|--help) show_help; exit 1 ;; | |
| *) show_help; exit 3 ;; | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment