lunes, 21 de diciembre de 2015

Script de permisos para Magento

Consideraciones iniciales:


  1. El usuario y grupo de apache son "www-data".
  2. El documentroot es "/var/www/html"

sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html/ -type d -exec chmod 500 {} \;
sudo find /var/www/html/ -type f -exec chmod 400 {} \;
sudo find /var/www/html/media -type d -exec chmod 700 {} \;
sudo find /var/www/html/var   -type d -exec chmod 700 {} \;
sudo find /var/www/html/media -type f -exec chmod 600 {} \;
sudo find /var/www/html/var   -type f -exec chmod 600 {} \;
sudo chmod 600 /var/www/html/includes/config.php
sudo chmod 700 /var/www/html/includes

jueves, 22 de octubre de 2015

SHELL, FUNCIONES PARA TRABAJAR CON ARCHIVOS EN HTDOCS

Como desarrollador de software en algunas ocasiones, es necesario realizar operaciones constantes sobre archivos lo cual a  más de uno nos a costado tener que reinstalar el kernel.

En está ocasión les presento algunas funciones de mi uso personal, las cuales me han ayudado a mitigar bastante este tipo de errores, antes de presentarlas quiero hacer énfasis en lo siguiente:
"Son funciones de mi uso personal, he decidido hacerlas públicas no como una recomendación, las hago públicas para que cualquiera que las encuentre útiles y quiera usarlas las adopte, ¿y por que no? las mejore".

En Bueno comenzamos, todo el código debe ir dentro del archivo .bashrc

#ESTA VARIABLE ES EL DocumentRoot DE NUESTROS PROYECTOS
HTDOCS=/var/www/html/

#####################################################################################################
# ESTA FUNCIÓN ES USADA PARA GENERAR EL AUTOCOMPLETE DE LAS FUNCIONES SIGUIENTES.
# POR EJEMPLO LA FUNCION cdw LA CUAL SIRVE PARA ACCEDER RÁPIDAMENTE A LAS SUBCARPETAS DE HTDOCS
#####################################################################################################
function _cdw(){
  directory=$HTDOCS
  cur="${COMP_WORDS[COMP_CWORD]}"
  curb=$(echo $cur | sed 's,[^/]*$,,')
  cmd="find $directory$curb -maxdepth 1 -type d -printf %p/\n "
  opts=$($cmd | sed s:$directory:: | sed s://*$:/:)
  COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
  return 0;
}

#####################################################################################################
# SIRVE PARA ACCEDER RÁPIDAMENTE A LAS SUBCARPETAS DE HTDOCS
# AL PRESIONAR <tab> AUTOCOMPLETA CON LAS SUBCARPETAS DE HTDOCS
#####################################################################################################
function cdw(){
    cd $HTDOCS$1
}
complete -o nospace -F _cdw cdw */

#####################################################################################################
# BORRA UNA SUBCARPETA DE HTDOCS
# AL PRESIONAR <tab> AUTOCOMPLETA CON LAS SUBCARPETAS DE HTDOCS
#####################################################################################################
function delete(){
if [ -z "$1" ]
    then
    echo "I CAN'T ERASE $HTDOCS"
else
    rm -rf $HTDOCS$1
fi
}

complete -o nospace -F _cdw delete */

#####################################################################################################
# CAMBIA LOS PERMISOS A UNA SUBCARPETA DE HTDOCS
# AL PRESIONAR <tab> AUTOCOMPLETA CON LAS SUBCARPETAS DE HTDOCS
#####################################################################################################
function shmod(){
    if [ -z "$2" ]
    then
        echo "I CAN'T CHANGE MODE TO $HTDOCS"
    else
        sudo chmod -R $1 $HTDOCS$2
    fi
}

complete -o nospace -F _cdw shmod */

martes, 7 de abril de 2015


LUNUX, FEDORA

Abrir aplicación si no se esta ejecutando , y si esta ejecutandose abrirla

sh -c "if test $(wmctrl -vxa nautilus 2>&1 | wc -l) -eq 1; then nautilus; fi"
sh -c "if test $(wmctrl -vxa chrome 2>&1 | wc -l) -eq 1; then google-chrome; fi"
sh -c "if test $(wmctrl -vxa phpstorm 2>&1 | wc -l) -eq 1; then phpstorm; fi"