You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.0 KiB

5 years ago
5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/bin/bash
  2. BASEDIR=$PWD
  3. function usage {
  4. echo 'usage: --host | --containers | --full'
  5. exit -1
  6. }
  7. function install_host {
  8. echo "install host"
  9. echo --------------
  10. [ `id -u` -ne 0 ] && echo 'root privilege required' && exit 1
  11. if [[ ! $BASEDIR == '/opt/debian-bash' ]]; then
  12. # download and filfull /opt/debian-bash, then run it from folder
  13. rm -rf /opt/debian-bash
  14. TEMP=`mktemp -d`
  15. cd $TEMP
  16. echo $TEMP
  17. wget https://git.artcode.re/pvincent/debian-bash/archive/master.tar.gz
  18. tar -xzf master.tar.gz
  19. mv debian-bash /opt/
  20. cd /opt/debian-bash
  21. ./install.sh --host
  22. rm -rf $TEMP
  23. exit 0
  24. else
  25. #remove /etc/skel/.bashrc
  26. rm /etc/skel/.bashrc
  27. ORIGINAL="ORIGINAL"
  28. declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc)
  29. for i in "${arr[@]}"
  30. do
  31. if [ ! -f "$i.$ORIGINAL" ]; then
  32. echo "$i needs installation $(basename $i)"
  33. mv "$i" "$i.$ORIGINAL"
  34. ln -s "$BASEDIR/$(basename $i)" "$i"
  35. else
  36. echo "$i" already overriden
  37. fi
  38. done
  39. source /etc/bash.bashrc
  40. fi
  41. }
  42. function install_containers {
  43. echo "install containers"
  44. echo --------------------
  45. # install inside active LXC containers
  46. if [[ -f '/snap/bin/lxc' ]]; then
  47. for container in `/snap/bin/lxc list -c n --format csv`; do
  48. echo "pushed to $container"
  49. /snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r
  50. /snap/bin/lxc exec "$container" -- sh -c "cd /opt/debian-bash && ./install.sh"
  51. done
  52. fi
  53. }
  54. function install_one_container {
  55. echo "install container <ONE>"
  56. echo -------------------------
  57. }
  58. PARAM1=$1
  59. case $PARAM1 in
  60. "--host")
  61. install_host
  62. ;;
  63. "--containers")
  64. install_containers
  65. ;;
  66. "--full")
  67. install_host
  68. install_containers
  69. ;;
  70. *)
  71. usage
  72. ;;
  73. esac