create-link.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. command -v debootstrap || exit 100
  3. BOOTSTRAP_BIN_FILE=$(which debootstrap)
  4. REAL_BOOTSTRAP_BIN_FILE=$(readlink -f ${BOOTSTRAP_BIN_FILE})
  5. echo "BOOTSTRAP_BIN_FILE=${BOOTSTRAP_BIN_FILE}"
  6. echo "REAL_BOOTSTRAP_BIN_FILE=${REAL_BOOTSTRAP_BIN_FILE}"
  7. SCRIPT_DIR=$(dirname $(readlink -f $0))
  8. if [ ${BOOTSTRAP_BIN_FILE} = ${REAL_BOOTSTRAP_BIN_FILE} ]; then
  9. TIMESTAMP=$(date '+%Y-%m-%d')
  10. echo "sudo mv ${BOOTSTRAP_BIN_FILE} ${BOOTSTRAP_BIN_FILE}-${TIMESTAMP}.bak"
  11. sudo mv ${BOOTSTRAP_BIN_FILE} ${BOOTSTRAP_BIN_FILE}-${TIMESTAMP}.bak
  12. echo "sudo ln -sf ${SCRIPT_DIR}/usr/sbin/debootstrap /usr/sbin/debootstrap"
  13. sudo ln -sf ${SCRIPT_DIR}/usr/sbin/debootstrap /usr/sbin/debootstrap
  14. echo "sudo mv /usr/share/debootstrap/functions{,-${TIMESTAMP}.bak}"
  15. sudo mv /usr/share/debootstrap/functions{,-${TIMESTAMP}.bak}
  16. echo "sudo ln -sf ${SCRIPT_DIR}/usr/share/debootstrap/functions /usr/share/debootstrap/functions"
  17. sudo ln -sf ${SCRIPT_DIR}/usr/share/debootstrap/functions /usr/share/debootstrap/functions
  18. echo "sudo mv /usr/share/debootstrap/scripts/gutsy{,-${TIMESTAMP}.bak}"
  19. sudo mv /usr/share/debootstrap/scripts/gutsy{,-${TIMESTAMP}.bak}
  20. echo "sudo ln -sf ${SCRIPT_DIR}/usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/gutsy"
  21. sudo ln -sf ${SCRIPT_DIR}/usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/gutsy
  22. fi
  23. # 查看文件软链接情况
  24. ls -lh /usr/sbin/debootstrap
  25. ls -lh /usr/share/debootstrap/functions
  26. ls -lh /usr/share/debootstrap/scripts/gutsy