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.

95 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
4 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 $PARAM1
  22. rm -rf $TEMP
  23. exit 0
  24. else
  25. #remove /etc/skel/.bashrc
  26. if [ -e /etc/skel/.bashrc ]; then
  27. rm /etc/skel/.bashrc
  28. fi
  29. ORIGINAL="ORIGINAL"
  30. declare -a arr=(/etc/bash.bashrc /etc/inputrc /etc/vim/vimrc)
  31. for i in "${arr[@]}"
  32. do
  33. if [ ! -f "$i.$ORIGINAL" ]; then
  34. echo "$i needs installation $(basename $i)"
  35. mv "$i" "$i.$ORIGINAL"
  36. ln -s "$BASEDIR/$(basename $i)" "$i"
  37. else
  38. echo "$i" already overriden
  39. fi
  40. done
  41. source /etc/bash.bashrc
  42. fi
  43. }
  44. function install_containers {
  45. echo "install containers"
  46. echo --------------------
  47. # install inside active LXC containers
  48. if [[ -f '/snap/bin/lxc' ]]; then
  49. for container in `/snap/bin/lxc list -c n --format csv`; do
  50. echo "pushed to $container"
  51. /snap/bin/lxc file push /opt/debian-bash "${container}/opt/" -r
  52. /snap/bin/lxc exec "$container" -- sh -c "cd /opt/debian-bash && ./install.sh --host"
  53. done
  54. fi
  55. }
  56. function install_one_container {
  57. echo "install container <ONE>"
  58. echo -------------------------
  59. }
  60. PARAM1=$1
  61. case $PARAM1 in
  62. "--host")
  63. install_host
  64. ;;
  65. "--containers")
  66. install_containers
  67. ;;
  68. "--full")
  69. install_host
  70. install_containers
  71. ;;
  72. *)
  73. usage
  74. ;;
  75. esac