Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # File: Iniciar
- echo '
- ## Sistema de carga para el servidor local
- ##
- ## @author Villalba Juan Manuel Pedro <https://github.com/juanma386>
- # @Version: 0.0.4
- # @Estado: Alpha
- # @Mail: hexomedesarrollos@gmail.com
- # @Comentario: Ayudarte a vos amigo que estas del otro lado luchando para entender todo esto, se que es dificil aprender pero todo se logra, acepto donaciones :D
- # @Destino: Deploy Server Php Linux
- # @Date: 05:41pm 14-09-2017
- # @Advertencia Usar con cautela y bajo propia responsabilidad
- # @Licence: GPLv2 Free Software Foundation <licensing@fsf.org>
- '
- _hoy=$(date +"%m_%d_%Y_%r_%S")
- _pwd=$(pwd)
- _permisos=$(ls -la *)
- createpublic(){
- if [ -d public_html ];
- then
- mkdir public_html
- chmod 775 public_html
- else
- echo "Hay un problema con los permisos, debes resolverlo"
- fi
- }
- # Agregada una decoración que me gusta mucho:
- PrintLogData(){
- cat <<EOF
- ## ###### ### ## ## ## ## ##
- ## ###### ### ## ## ## :## ##:
- ## ## ###: ## ## ## ## ##
- ## ## #### ## ## ## :####:
- ## ## ##:#: ## ## ## ####
- ## ## ## ## ## ## ## :##:
- ## ## ## ## ## ## ## :##:
- ## ## ## :#:## ## ## ####
- ## ## ## #### ## ## :####:
- ## ## ## :### ## ## ##::##
- ######## ###### ## ### :######: :## ##:
- ######## ###### ## ### :####: ## ##
- EOF
- }
- bin(){
- if [ -d bin ];
- then
- echo "Sí, sí existe."
- echo "Data is exist in bin folder". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ./bin existe OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ./bin OK ". " [ "$_pwd" ]"
- else
- echo "No, no existe"
- echo "File does not exist"
- echo "Create Directory"
- mkdir bin
- echo "Directorio de bin creado OK ". " [ "$_pwd" ]" >> testing.server.log
- fi
- }
- bin
- # Registro del sistema
- registro() {
- logger=./testing.server.log
- if [ ! -e "$logger" ];
- then
- echo "Log operative not found init process charging data"
- echo '
- ## Part Deploy working
- ##
- ## @author Villalba Juan Manuel Pedro <https://github.com/juanma386>
- # @Version: 0.0.1
- # @Estado: Alpha
- # @Destino: Deploy Server Php Linux
- # @Date: 05:41pm 14-09-2017
- # @Advertencia Usar con cautela y bajo propia responsabilidad
- # @Licence: GPLv2 Free Software Foundation <licensing@fsf.org>
- ' > testing.server.log
- echo "Finish file logger is created and continue process"
- else
- echo "Data file log is existed". " [ ".$_hoy." ]"
- # echo "Los permisos del archivo" $_permisos
- echo "Data file log is existed". " [ ".$_hoy." ]" >> testing.server.log
- echo "Los permisos del archivo" $_permisos >> testing.server.log
- PrintLogData
- fi
- }
- registro
- SEPARADOR(){
- cat <<EOF
- #####################################################
- #####################################################
- #####################################################
- #####################################################
- EOF
- }
- SEPARADOR
- server() {
- servidor=./bin/servicio.sh
- if [ ! -e "$servidor" ];
- then
- echo "File does not exist sh"
- echo "Download sh deployer to system_". "[".$_hoy."]"
- curl -o bin/servicio.sh https://pastebin.com/raw/RA8w25Vu
- echo 'Downloading finish OK'
- echo 'Verificando Permisos'
- echo "Downloadings data sh to working deploy ". " [ ".$_hoy." ]" >> testing.server.log
- dos2unix $_pwd/./*/servicio.sh
- permisosverificarserver
- else
- echo "Data Deploy is existed". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]"
- fi
- }
- SEPARADOR
- # Permisos del servicio.sh
- permisosverificarserver(){
- if [ ! -x "$_pwd/./*/servicio.sh" ];
- then
- echo 'Delegando permisos'
- echo "Error en permisos del sistema......FAIL". " [ ".$_hoy." ]" >> testing.server.log
- chmodbin
- else
- echo 'Permisos de ejecución estan correctos'
- echo "Permisos de ejecución................OK". " [ ".$_hoy." ]" >> testing.server.log
- fi
- }
- SEPARADOR
- chmodbin(){
- chmod +x bin/servicio.sh
- }
- SEPARADOR
- server
- public(){
- if [ -d public_html ];
- then
- echo "Sí, sí existe."
- echo "Data is exist in bin folder". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ./publi_html OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ./publi_html OK ". " [ "$_pwd" ]"
- else
- echo "No, no existe"
- echo "File does not exist"
- echo "Create Directory"
- mkdir public_html
- chmod 755 public_html
- echo "Directorio de bin creado OK ". " [ "$_pwd" ]" >> testing.server.log
- exit
- fi
- }
- #public
- SEPARADOR
- route() {
- fileroute=./bin/route.php
- if [ ! -e "$fileroute" ];
- then
- echo "File does not exist"
- echo "Create Directory"
- mkdir bin
- echo "Route data deploy work download". "[".$_hoy."]"
- echo "Downloading data in progress"
- curl -o bin/route.php https://pastebin.com/raw/dLFnEQvz
- echo "preparing deployer to inicializated ". " [ ".$_hoy." ]" >> testing.server.log
- permisosverificarroute
- else
- echo "Data is exist in bin folder". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]"
- echo 'Listo todo esta instalado y listo para empezar'
- fi
- }
- route
- SEPARADOR
- # Verificando la existencia del archivo bin/servicio.sh
- verificar_servicio(){
- servidor=./bin/servicio.sh
- if [ ! -e "$servidor" ];
- then
- echo "File does not exist sh"
- echo "Download sh deployer to system_". "[".$_hoy."]"
- server_shell
- echo 'Downloading finish OK'
- echo 'Verificando Permisos'
- echo "Downloadings data sh to working deploy ". " [ ".$_hoy." ]" >> testing.server.log
- dos2unix $_pwd/./*/servicio.sh
- permisosverificarserver
- else
- echo "Data Deploy is existed". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]"
- fi
- }
- verificar_servicio
- sh bin/servicio.sh
- server() {
- servidor=./bin/servicio.sh
- if [ ! -e "$servidor" ];
- then
- echo "File does not exist sh"
- echo "Download sh deployer to system_". "[".$_hoy."]"
- curl -o bin/servicio.sh https://pastebin.com/raw/RA8w25Vu
- echo 'Downloading finish OK'
- echo 'Verificando Permisos'
- echo "Downloadings data sh to working deploy ". " [ ".$_hoy." ]" >> testing.server.log
- dos2unix $_pwd/./*/servicio.sh
- permisosverificarserver
- else
- echo "Data Deploy is existed". " [ ".$_hoy." ]"
- echo "Data deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]" >> testing.server.log
- echo "Directorio de ejecución OK ". " [ "$_pwd" ]"
- fi
- }
- # Permisos del servicio.sh
- permisosverificarserver(){
- if [ ! -x "$_pwd/./*/servicio.sh" ];
- then
- echo 'Delegando permisos'
- echo "Error en permisos del sistema......FAIL". " [ ".$_hoy." ]" >> testing.server.log
- chmodbin
- else
- echo 'Permisos de ejecución estan correctos'
- echo "Permisos de ejecución................OK". " [ ".$_hoy." ]" >> testing.server.log
- fi
- }
- chmodbin(){
- chmod +x bin/servicio.sh
- }
- # Verificando estado de config.ini
- # Integramos datos en esta version 2.09 21042019 yuma2020 Juan Manuel Pedro Villalba
- crear_config(){
- echo '
- servidor=127.0.0.1
- puerto=8000
- usuario=NOCORRESPONDE
- password=NOCORRESPONDE
- ' > config.ini
- }
- check_config() {
- fileconfig=./config.ini
- if [ ! -e "$fileconfig" ];
- then
- echo "File does not exist"
- echo "Al parecer no existe este archivo"
- echo "El archivo config.ini no existe". " [ ".$_hoy." ]" >> testing.server.log
- crear_config
- echo "configdata deploy work created". "[".$_hoy."]"
- else
- echo "Data is exist in config_ini folder". " [ ".$_hoy." ]"
- echo "Data config_ini deploy is existed OK ". " [ "$_hoy" ]" >> testing.server.log
- echo 'Listo todo esta instalado y listo para desplegar'
- fi
- }
- check_config
- # Agregado en la version 2.10 24042019
- random(){
- shuf -i 1-65555 -n 1
- }
- cambio_de_puertas=$(random)
- resolver_puerto_ochomil(){
- S1='8000'
- S2=$PORT
- if [ $S1!=$S2 ];
- then
- echo "S1('$S1') no es igual a S2('$S2')"
- echo "Podemos continual con los trabajos de despliegues"
- fi
- if [ $S1=$S1 ];
- then
- echo "S1('$S1') es igual a S1('$S1')"
- echo "Se cambiara toda la configuración para que se brinde un medio donde trabajar comodamente durante el despliegue"
- echo "Se ha cambiado el puerto: S1('$S1') Pedido ". " [ "$_hoy" ]" >> testing.server.log
- echo "Se ha cambiado el puerto S1('$S1') por el puerto S2('$S2')". " [ "$_pwd" ]" >> testing.server.log
- find ./* -name "config.ini" -print | xargs sed -i "s/8000/$cambio_de_puertas/g"
- fi
- }
- resolver_puerto_ochomil
- server
- sh bin/servicio.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement