Skip to content

Instantly share code, notes, and snippets.

View hn-support's full-sized avatar

Hypernode Support hn-support

View GitHub Profile
@hn-support
hn-support / cron-debugger.sh
Last active December 26, 2020 18:19
Debug script to log all cron output to a logfile
#!/bin/bash
# This script is a debug utility for cronjobs as explained in:
# - https://support.hypernode.com/knowledgebase/configure-cronjobs-on-hypernode/
# It logs all output and timing to a log file
#
# To use it, download the script, add the executable bit and put it in your cronjob:
# */5 * * * * /data/web/bin/debug-cron php -f /data/web/public/cron.php
LOGDIR="/data/web/public/var/log/crons"
TIMESTAMP="$( date '+%Y%m%d%H%M' )"
@hn-support
hn-support / change_magento1_staging_baseurls.py
Last active June 10, 2020 19:01
Change your base_urls for Magento 1 staging environment on hypernode
#!/usr/bin/env python
"""
Set the base-urls for your Magento 1 staging environment by copying and adjusting the base-urls from your production site.
To use, download the file and make it executable. Then run:
./change_magento1_staging_baseurls.py
After use, check your base-urls by issuing:
n98-magerun sys:store:config:base-url:list
This script requires n98-magerun.
#!/usr/bin/env python
""" Hypernode searchd cron watchdog
This script checks the pid of the searchd daemon and restarts it when the service is not running
It works for both Magento 1 and Magento 2 and for both live and staging.
To run it, add it to the crontab of your hypernode.
For Magento 1:
* * * * * flock -n ~/.searchd_live /data/web/searchd-watchdog.py --environment live --version 1 (live)
@hn-support
hn-support / server.shopware
Last active January 28, 2020 15:11
Shopware Nginx configuration
## Author: Benjamin Cremer
## Shopware nginx rules.
## Heavily Inspired by https://github.com/perusio/drupal-with-nginx/
## Designed to be included in any server {} block.
## Please note that you need a PHP-FPM upstream configured in the http context, and its name set in the $fpm_upstream variable.
## https://github.com/bcremer/shopware-with-nginx
# don't log favicon hits
location = /favicon.ico {
log_not_found off;
vcl 4.0;
import std;
# The minimal Varnish version is 4.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
backend default {
.host = "127.0.0.1";
.port = "8080";
}
@hn-support
hn-support / robots.txt
Created March 30, 2017 12:00
Magento 2 recommended additions for robots.txt
User-agent: *
# Directories
Disallow: /app/
Disallow: /bin/
Disallow: /dev/
Disallow: /lib/
Disallow: /phpserver/
Disallow: /pkginfo/
Disallow: /report/
@hn-support
hn-support / Example snippet server.shopware
Last active February 22, 2019 09:02
Example Shopware Nginx rewrites
###General rewrites
location @shopware {
rewrite / /shopware.php;
}
# use shopware.php as index.php
location ~ ^/ {
# rewrite / /shopware.php;
index shopware.php index.php;
@hn-support
hn-support / change_magento2_base_urls_to_https.py
Last active February 20, 2019 10:13
Change all base_urls of your Magento 2 live shop to https on hypernode
#!/usr/bin/env python
"""
Set the base-urls for your Magento 2 installation to support only https.
To use, download the file and make it executable. Then run:
./change_magento2_base_urls_to_https.py
After use, check your base-urls by issuing:
n98-magerun2 sys:store:config:base-url:list
This script requires n98-magerun2.
@hn-support
hn-support / use-geoip-data-in.php
Last active January 14, 2019 08:38
How to use geoip data in php on hypernodes
<?php
/*
This script is a basic example of how to use GeoIP data in PHP.
It returns an overview of all available constants retrieved from the Maxmind GeoIP databases.
*/
$elements = array(
"country_code" => getenv('GEOIP_COUNTRY_CODE'),
"country_code3" => getenv('GEOIP_COUNTRY_CODE3'),
"country_name" => getenv('GEOIP_COUNTRY_NAME'),
@hn-support
hn-support / block-version-control-on-nginx.md
Last active January 13, 2018 03:05
block version control directory on nginx
# Skip .git, .htpasswd etc
location ~ /\.(git|svn|ht) {
    return 404;
}