Skip to content

Commit

Permalink
Finish installer macos, need clean old methods
Browse files Browse the repository at this point in the history
  • Loading branch information
raupulus committed Jul 22, 2022
1 parent 7ed1781 commit 5f86fe0
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ npm-debug.log
__pycache__
/.env
__init__.py
.DS_Store
5 changes: 3 additions & 2 deletions Repositorios/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ agregarRepositoriosMacos() {
## Declaro tty para firmas gpg si hiciera falta
export GPG_TTY=$(tty)

if [[ !-d ~/.gnupg/gpg-agent.conf ]];then
if [[ ! -d "${HOME}/.gnupg/gpg-agent.conf" ]];then
echo 'pinentry-program /usr/local/bin/pinentry-mac' > ~/.gnupg/gpg-agent.conf
fi

Expand All @@ -51,6 +51,7 @@ agregarRepositoriosMacos() {
brew install wget

## Añado más repositorios a HomeBrew
brew tap homebrew/core
brew tap homebrew/cask-versions

## Repositorio de mongodb https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/
Expand All @@ -60,7 +61,7 @@ agregarRepositoriosMacos() {
brew install --cask cakebrew

## Instalo llavero gpg: https://gist.github.com/troyfontaine/18c9146295168ee9ca2b30c00bd1b41e
brew install gpg2 gnupg pinentry-mac
brew install gnupg pinentry-mac gpg-suite

if [[ ! -d $HOME/.gnupg ]]; then
mkdir "${HOME}/.gnupg"
Expand Down
4 changes: 2 additions & 2 deletions routes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ routesApache2() {
echo -e "$VE Configurando directorios apache para $DISTRO$CL"
APACHECONF='/opt/homebrew/etc/httpd'
DIRWEBLOG='/var/log/apache2'
DIRWEB="/opt/homebrew/opt/httpd"
APACHESITES="${APACHECONF}/vhosts.conf"
DIRWEB="/Users/${USER}/www"
APACHESITES="${APACHECONF}/extra/httpd-vhosts.conf"
APACHESITESENABLED=""
APACHEPORTSCONF="${APACHECONF}/ports.conf"
APACHEAPACHE2CONF="${APACHECONF}/httpd.conf"
Expand Down
140 changes: 130 additions & 10 deletions servers/apache2/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ apache2_after_install() {
echo -e "$VE Acciones tras instalar$RO Apache2$CL"

if [[ $DISTRO = 'macos' ]]; then
brew services start httpd
#brew services start httpd
sudo apachectl start

if [[ !-f $APACHESITES ]];then
if [[ ! -f $APACHESITES ]];then
sudo touch $APACHESITES
sudo chmod ${USER}:admin $APACHESITES
sudo chown ${USER}:admin $APACHESITES
sudo chmod 644 $APACHESITES
fi

if [[ !-f $APACHEPORTSCONF ]];then
if [[ ! -f $APACHEPORTSCONF ]];then
sudo touch $APACHEPORTSCONF
sudo cp "$WORKSCRIPT/conf/etc/apache2/ports.conf" "$APACHEPORTSCONF"
sudo chmod ${USER}:admin $APACHESITES
sudo chown ${USER}:admin $APACHEPORTSCONF
sudo chmod 644 $APACHEPORTSCONF
fi


Expand All @@ -98,10 +101,19 @@ apache2_after_install() {
sudo cp ${WORKSCRIPT}/conf/etc/apache2/mods-available/* "$APACHEMODS"
fi

## Creo almacenamiento para aplicaciones
if [[ ! -d "${DIRWEB}" ]]; then
sudo mkdir "${DIRWEB}"
sudo chown ${USER}:www-data -R "${DIRWEB}"
sudo chmod 770 -R "${DIRWEB}"
sudo chmod ug+s -R "${DIRWEB}"
sudo umask 117 -R "${DIRWEB}"
fi

## Creo almacenamiento para aplicaciones
if [[ ! -d "${DIRWEB}/storage" ]]; then
sudo mkdir "${DIRWEB}/storage"
sudo chown www-data:www-data -R "${DIRWEB}/storage"
sudo chown ${USER}:www-data -R "${DIRWEB}/storage"
sudo chmod 770 -R "${DIRWEB}/storage"
sudo chmod ug+s -R "${DIRWEB}/storage"
sudo umask 117 -R "${DIRWEB}/storage"
Expand Down Expand Up @@ -277,12 +289,12 @@ apache2DefaultSiteSecurity() {
##
apache2GenerarEnlaces() {
## Creo enlace al directorio web.
if [[ ! -h "$HOME/web" ]] &&
if [[ ! -h "$HOME/www" ]] &&
[[ -d "$DIRWEB" ]]; then
echo -e "$VE Creando enlace desde$RO ${HOME}/web$VE hasta$RO $DIRWEB$CL"
echo -e "$VE Creando enlace desde$RO ${HOME}/www$VE hasta$RO $DIRWEB$CL"

sudo ln -s "$DIRWEB" "${HOME}/web"
sudo chown "$USER:www-data" "${HOME}/web"
sudo ln -s "$DIRWEB" "${HOME}/www"
sudo chown "$USER:www-data" "${HOME}/www"
fi

## Creo enlace a repositorios "git" en zona privada.
Expand All @@ -296,7 +308,115 @@ apache2GenerarEnlaces() {
fi
}

apache2_macos_installer() {
sudo apachectl stop 2>/dev/null
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

if [[ -d "${HOME}/git" ]]; then
sudo chown -R ${USER}:staff "${HOME}/git"
sudo chmod -R g+s "${HOME}/git"
sudo su root -c "umask 117 -R ${HOME}/git"
fi

## Creo almacenamiento para aplicaciones
if [[ ! -d "${DIRWEB}" ]]; then
sudo mkdir "${DIRWEB}"
sudo chown -R ${USER}:staff "${DIRWEB}"
sudo chmod -R 770 "${DIRWEB}"
sudo chmod -R ug+s "${DIRWEB}"
sudo umask 117 -R "${DIRWEB}"
fi

## Creo almacenamiento para aplicaciones
if [[ ! -d "${DIRWEB}/storage" ]]; then
sudo mkdir "${DIRWEB}/storage"
sudo chown -R ${USER}:staff "${DIRWEB}/storage"
sudo chmod -R 770 "${DIRWEB}/storage"
sudo chmod -R ug+s "${DIRWEB}/storage"
sudo umask 117 -R "${DIRWEB}/storage"
fi

## Creo lugar para sitios públicos
if [[ ! -d "${DIRWEB}/public" ]]; then
sudo mkdir "${DIRWEB}/public"
sudo chown -R ${USER}:staff "${DIRWEB}/public"
sudo chmod -R 770 "${DIRWEB}/public"
sudo chmod -R ug+s "${DIRWEB}/public"
sudo umask 117 -R "${DIRWEB}/public"
fi

## Creo lugar para sitios públicos
if [[ ! -d "${DIRWEB}/public/default" ]]; then
sudo mkdir "${DIRWEB}/public/default"
sudo touch "${DIRWEB}/public/default/index.html"
sudo chown -R ${USER}:staff "${DIRWEB}/public/default"
sudo chmod -R 770 "${DIRWEB}/public/default"
sudo chmod -R ug+s "${DIRWEB}/public/default"
sudo umask 117 -R "${DIRWEB}/public/default"

echo '<h1>Sitio por defecto Creado</h1>' > "${DIRWEB}/public/default/index.html"
fi

## Creo lugar para sitios privados
if [[ ! -d "${DIRWEB}/private" ]]; then
sudo mkdir "${DIRWEB}/private"
sudo chown -R ${USER}:staff "${DIRWEB}/private"
sudo chmod -R 770 "${DIRWEB}/private"
sudo chmod -R ug+s "${DIRWEB}/private"
sudo umask 117 -R"${DIRWEB}/private"
fi

apache2DefaultSiteSecurity

if [[ -f "${DIRWEB}/.htpasswd" ]]; then
sudo chown ${USER}:staff "${DIRWEB}/.htpasswd"
fi

## Creo enlace a repositorios "git" en zona privada.
if [[ -d "$HOME/git" ]] &&
[[ "$ENV" = 'dev' ]] &&
[[ -d "${DIRWEB}/private" ]] &&
[[ ! -h "${DIRWEB}/private/git" ]];
then
echo -e "$VE Creando enlace desde$RO ${HOME}/git$VE hasta$RO ${DIRWEB}/private$CL"
sudo ln -s "$HOME/git" "${DIRWEB}/private/git"
fi

brew install httpd

which apachectl

sudo apachectl -k start
brew services start httpd

## Comprobar problemas al iniciar apache, monitorizar:
#tail -n 500 -f /opt/homebrew/var/log/httpd/error_log

## Comprobar accesos
#tail -n 500 -f /opt/homebrew/var/log/httpd/access_log

## Directorio de configuraciones
#/opt/homebrew/etc/httpd

## Comandos de gestión apache
#sudo apachectl start
#sudo apachectl stop
#sudo apachectl -k restart
#sudo apachectl configtest


cd /opt/homebrew/etc/httpd
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
cd $WORKSCRIPT
}

apache2_installer() {

if [[ $DISTRO = 'macos' ]]; then
apache2_macos_installer
return
fi

apache2_download
apache2_before_install
apache2_install
Expand Down
2 changes: 1 addition & 1 deletion servers/mariaDB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mariadb_postconfiguracion() {
brew services start mariadb
mysql_install_db
mysql_upgrade
#sudo mariadb-secure-installation
sudo mariadb-secure-installation

echo -e "$VE Estableciendo character-set-server = utf8mb4$CL"
sudo sed -r -i'' "s/^\s*#?\s*character-set-server\s*=.*/character-set-server = utf8mb4/" "$FILE_CONF"
Expand Down

0 comments on commit 5f86fe0

Please sign in to comment.