1
0

apacheon.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. online(){
  3. i="1"
  4. [[ -z $(ls $HOME) ]] && msg -bar || {
  5. for my_arqs in `ls $HOME`; do
  6. [[ -d "$my_arqs" ]] && continue
  7. select_arc[$i]="$my_arqs"
  8. echo -e " $(msg -verd "[$i]") $(msg -verm2 ">") $(msg -ama "$my_arqs")"
  9. let i++
  10. done
  11. i=$(($i - 1))
  12. msg -bar
  13. while [[ -z ${select_arc[$slct]} ]]; do
  14. msg -nama "$(fun_trans "Seleccione un archivo") [1-$i]: "
  15. read slct
  16. tput cuu1 && tput dl1
  17. done
  18. arquivo_move="${select_arc[$slct]}"
  19. [ ! -d /var ] && mkdir /var
  20. [ ! -d /var/www ] && mkdir /var/www
  21. [ ! -d /var/www/html ] && mkdir /var/www/html
  22. [ ! -e /var/www/html/index.html ] && touch /var/www/html/index.html
  23. [ ! -e /var/www/index.html ] && touch /var/www/index.html
  24. chmod -R 755 /var/www
  25. cp $HOME/$arquivo_move /var/www/$arquivo_move
  26. cp $HOME/$arquivo_move /var/www/html/$arquivo_move
  27. clear
  28. msg -bar
  29. print_center -verd "ARCHIVO EN LINEA"
  30. msg -bar
  31. print_center -teal "http://$IP:81/$arquivo_move"
  32. msg -bar
  33. enter
  34. }
  35. }
  36. rm_online(){
  37. i=1
  38. [[ -z $(ls /var/www/html) ]] && msg -bar || {
  39. for my_arqs in `ls /var/www/html`; do
  40. [[ "$my_arqs" = "index.html" ]] && continue
  41. [[ "$my_arqs" = "index.php" ]] && continue
  42. [[ -d "$my_arqs" ]] && continue
  43. select_arc[$i]="$my_arqs"
  44. echo -e "$(msg -verd "[$i]") $(msg -verm2 ">") $(msg -teal "http://$IP:81/$my_arqs")"
  45. let i++
  46. done
  47. msg -bar
  48. while [[ -z ${select_arc[$slct]} ]]; do
  49. msg -nama "$(fun_trans "Seleccione el archivo que desea borrar") [1-$i]: "
  50. read slct
  51. tput cuu1 && tput dl1
  52. done
  53. arquivo_move="${select_arc[$slct]}"
  54. [[ -d /var/www/html ]] && [[ -e /var/www/html/$arquivo_move ]] && rm -rf /var/www/html/$arquivo_move > /dev/null 2>&1
  55. [[ -e /var/www/$arquivo_move ]] && rm -rf /var/www/$arquivo_move > /dev/null 2>&1
  56. clear
  57. msg -bar
  58. print_center -verd "ARCHIVO REMOVIDO"
  59. msg -bar
  60. print_center -teal "http://$IP:81/$arquivo_move"
  61. msg -bar
  62. enter
  63. }
  64. }
  65. Links(){
  66. [[ -z $(ls /var/www/html) ]] && print_center -ama "SIN ARCHIVOS EN LINEA" || {
  67. for my_arqs in `ls /var/www/html`; do
  68. [[ "$my_arqs" = "index.html" ]] && continue
  69. [[ "$my_arqs" = "index.php" ]] && continue
  70. [[ -d "$my_arqs" ]] && continue
  71. echo -e " $(msg -verd "[$my_arqs]") $(msg -teal "http://$IP:81/$my_arqs")"
  72. done
  73. enter
  74. }
  75. }
  76. start(){
  77. IP="$(fun_ip)"
  78. clear
  79. msg -bar
  80. print_center -ama "Gestor de Archivos FTP"
  81. msg -bar
  82. menu_func "Colocar Archivo Online" "Remover Archivo Online" "Ver Links de Archivos Online"
  83. back
  84. opcion=$(selection_fun 3)
  85. case $opcion in
  86. 1)online;;
  87. 2)rm_online;;
  88. 3)Links;;
  89. 0)return 1;;
  90. esac
  91. }
  92. [[ $(dpkg --get-selections|grep -w "apache2"|head -1) ]] || {
  93. apt-get install apache2 -y &>/dev/null
  94. sed -i "s;Listen 80;Listen 81;g" /etc/apache2/ports.conf
  95. service apache2 restart > /dev/null 2>&1 &
  96. }
  97. start