Moves binaries for use with gnu stow

This commit is contained in:
Jonathan Hodgson 2019-07-30 14:06:10 +01:00
parent f528ba793c
commit 4fd9f4809b
89 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,353 @@
#!/bin/bash
DIR="$PWD"
#
#while test $# -gt 0; do
# case "$1" in
# --uploads)
# shift
# uploads=$1
# if [ ${uploads:0:1} == "-" ]; then
# uploads=""
# else
# shift
# fi
# ;;
# -h|--help)
# echo -e "htaccess Generator"
# echo -e "This generates an htaccess file"
# echo -e "It adds 301 redirects to the new locations of wp-includes and wp-admin"
# echo -e "It also sets up 301 redirects to or from the www version of the site"
# echo -e "For use on dev or local sites, you can specify a url to have for the wp-uploads"
# echo -e " "
# echo -e "Options"
# echo -e "-h, --help \t\t\t Show this help"
# echo -e "--uploads [url] \t\t\t The URL to redirect uploads to"
# echo -e "--with-www \t\t\t Indicate that the primary site should have www"
# echo -e "--without-www \t\t\t Indicate that the primary site shouldn't have www"
# echo -e "--domain [domain]\t\t\t The domain without www or http etc."
# exit 0
# ;;
# -a|--auto)
# defaults=true
# shift
# ;;
# --with-www)
# www="with"
# shift
# ;;
# --without-www)
# www="without"
# shift
# ;;
# --domain)
# shift
# domain=$1
# if [ ${domain:0:1} == "-" ]; then
# domain=""
# else
# shift
# fi
# ;;
# *)
# echo -e "You entered something that wasn't help or salt"
# shift
# ;;
# esac
#
#done
if [ -f "$DIR/.htaccess" ]; then
echo -e "The file .htaccess already exists."
echo -e "What do you want to do? [ b=Create Backup | o=Overwrite | a=Abort] \c"
read choice
choice=$(echo -e $choice | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ "$choice" == "b" ]]; then
name=".htaccess.backup$(date +'%y:%m:%d:%T')"
mv "$DIR/.htaccess" "$DIR/$name"
echo -e "Would you like to add this new file to .gitignore? [Y/n] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ $input != 'n' ]];then
echo "$name" >> .gitignore
fi
fi
if [[ "$choice" == "a" ]]; then
echo -e "Aborted by user"
return 1
fi
rm "$DIR/.htaccess"
fi
echo -e "Will you be running wordpress from a wp subdirectory? [Y/n] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ $input != 'n' ]]; then
subdirectory="true"
else
subdirectory="false"
fi
# Little hack to make any 404 urls set in .htaccess use the wp 404 page
echo 'ErrorDocument 404 /404/' > "$DIR/.htaccess"
# If wordpress is installed in a sub-directory, add redirects
if [[ "subdirectory" == "true" ]]; then
echo 'RedirectMatch 301 ^/wp-admin/(.*)$ /wp/wp-admin/$1' >> "$DIR/.htaccess"
echo 'RedirectMatch 301 ^/wp-includes/(.*)$ /wp/wp-includes/$1' >> "$DIR/.htaccess"
fi
#This makes sure all git folders and files are inaccessible
echo 'RedirectMatch 404 /\.git' >> "$DIR/.htaccess"
#This makes sure aquariusGo is not accessible
echo 'RedirectMatch 404 ^/aquariusGo' >> "$DIR/.htaccess"
#This makes sure htaccess is not accessible
echo 'RedirectMatch 404 ^/\.htaccess' >> "$DIR/.htaccess"
echo -e "Would you like to add cache, expire and gzip rules? [Y/n] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ $input != 'n' ]]; then
cacheRules="true"
else
cacheRules="false"
fi
if [[ "$cacheRules" == "true" ]]; then
echo '# Add Browser Cache expires rules' >> "$DIR/.htaccess"
echo '<IfModule mod_mime.c>' >> "$DIR/.htaccess"
echo ' AddType text/css .css' >> "$DIR/.htaccess"
echo ' AddType text/x-component .htc' >> "$DIR/.htaccess"
echo ' AddType application/x-javascript .js' >> "$DIR/.htaccess"
echo ' AddType application/javascript .js2' >> "$DIR/.htaccess"
echo ' AddType text/javascript .js3' >> "$DIR/.htaccess"
echo ' AddType text/x-js .js4' >> "$DIR/.htaccess"
echo ' AddType text/html .html .htm' >> "$DIR/.htaccess"
echo ' AddType text/richtext .rtf .rtx' >> "$DIR/.htaccess"
echo ' AddType image/svg+xml .svg .svgz' >> "$DIR/.htaccess"
echo ' AddType text/plain .txt' >> "$DIR/.htaccess"
echo ' AddType text/xsd .xsd' >> "$DIR/.htaccess"
echo ' AddType text/xsl .xsl' >> "$DIR/.htaccess"
echo ' AddType text/xml .xml' >> "$DIR/.htaccess"
echo ' AddType video/asf .asf .asx .wax .wmv .wmx' >> "$DIR/.htaccess"
echo ' AddType video/avi .avi' >> "$DIR/.htaccess"
echo ' AddType image/bmp .bmp' >> "$DIR/.htaccess"
echo ' AddType application/java .class' >> "$DIR/.htaccess"
echo ' AddType video/divx .divx' >> "$DIR/.htaccess"
echo ' AddType application/msword .doc .docx' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-fontobject .eot' >> "$DIR/.htaccess"
echo ' AddType application/x-msdownload .exe' >> "$DIR/.htaccess"
echo ' AddType image/gif .gif' >> "$DIR/.htaccess"
echo ' AddType application/x-gzip .gz .gzip' >> "$DIR/.htaccess"
echo ' AddType image/x-icon .ico' >> "$DIR/.htaccess"
echo ' AddType image/jpeg .jpg .jpeg .jpe' >> "$DIR/.htaccess"
echo ' AddType application/json .json' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-access .mdb' >> "$DIR/.htaccess"
echo ' AddType audio/midi .mid .midi' >> "$DIR/.htaccess"
echo ' AddType video/quicktime .mov .qt' >> "$DIR/.htaccess"
echo ' AddType audio/mpeg .mp3 .m4a' >> "$DIR/.htaccess"
echo ' AddType video/mp4 .mp4 .m4v' >> "$DIR/.htaccess"
echo ' AddType video/mpeg .mpeg .mpg .mpe' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-project .mpp' >> "$DIR/.htaccess"
echo ' AddType application/x-font-otf .otf' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-opentype ._otf' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.database .odb' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.chart .odc' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.formula .odf' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.graphics .odg' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.presentation .odp' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.spreadsheet .ods' >> "$DIR/.htaccess"
echo ' AddType application/vnd.oasis.opendocument.text .odt' >> "$DIR/.htaccess"
echo ' AddType audio/ogg .ogg' >> "$DIR/.htaccess"
echo ' AddType application/pdf .pdf' >> "$DIR/.htaccess"
echo ' AddType image/png .png' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx' >> "$DIR/.htaccess"
echo ' AddType audio/x-realaudio .ra .ram' >> "$DIR/.htaccess"
echo ' AddType application/x-shockwave-flash .swf' >> "$DIR/.htaccess"
echo ' AddType application/x-tar .tar' >> "$DIR/.htaccess"
echo ' AddType image/tiff .tif .tiff' >> "$DIR/.htaccess"
echo ' AddType application/x-font-ttf .ttf .ttc' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-opentype ._ttf' >> "$DIR/.htaccess"
echo ' AddType audio/wav .wav' >> "$DIR/.htaccess"
echo ' AddType audio/wma .wma' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-write .wri' >> "$DIR/.htaccess"
echo ' AddType application/font-woff .woff' >> "$DIR/.htaccess"
echo ' AddType application/font-woff2 .woff2' >> "$DIR/.htaccess"
echo ' AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw' >> "$DIR/.htaccess"
echo ' AddType application/zip .zip' >> "$DIR/.htaccess"
echo '</IfModule>' >> "$DIR/.htaccess"
echo '<IfModule mod_expires.c>' >> "$DIR/.htaccess"
echo ' ExpiresActive On' >> "$DIR/.htaccess"
echo ' ExpiresByType text/css A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType text/x-component A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-javascript A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/javascript A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType text/javascript A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType text/x-js A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType text/html A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType text/richtext A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType image/svg+xml A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType text/plain A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType text/xsd A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType text/xsl A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType text/xml A3600' >> "$DIR/.htaccess"
echo ' ExpiresByType video/asf A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType video/avi A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/bmp A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/java A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType video/divx A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/msword A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-fontobject A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-msdownload A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/gif A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-gzip A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/x-icon A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/jpeg A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/json A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-access A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/midi A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType video/quicktime A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/mpeg A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType video/mp4 A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType video/mpeg A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-project A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-font-otf A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-opentype A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.database A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.chart A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.formula A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.graphics A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.presentation A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.oasis.opendocument.text A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/ogg A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/pdf A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/png A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-powerpoint A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/x-realaudio A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/svg+xml A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-shockwave-flash A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-tar A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType image/tiff A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/x-font-ttf A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-opentype A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/wav A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType audio/wma A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-write A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/font-woff A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/font-woff2 A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/vnd.ms-excel A31536000' >> "$DIR/.htaccess"
echo ' ExpiresByType application/zip A31536000' >> "$DIR/.htaccess"
echo '</IfModule>' >> "$DIR/.htaccess"
#Add Gzip Compression
echo '<IfModule mod_deflate.c>' >> "$DIR/.htaccess"
echo ' # force deflate for mangled headers' >> "$DIR/.htaccess"
echo ' # developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/' >> "$DIR/.htaccess"
echo ' <IfModule mod_setenvif.c>' >> "$DIR/.htaccess"
echo ' <IfModule mod_headers.c>' >> "$DIR/.htaccess"
echo ' SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding' >> "$DIR/.htaccess"
echo ' RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding' >> "$DIR/.htaccess"
echo ' </IfModule>' >> "$DIR/.htaccess"
echo ' </IfModule>' >> "$DIR/.htaccess"
echo '' >> "$DIR/.htaccess"
echo ' # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:' >> "$DIR/.htaccess"
echo ' <IfModule filter_module>' >> "$DIR/.htaccess"
echo ' FilterDeclare COMPRESS' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf' >> "$DIR/.htaccess"
echo ' FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype' >> "$DIR/.htaccess"
echo ' FilterChain COMPRESS' >> "$DIR/.htaccess"
echo ' FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no' >> "$DIR/.htaccess"
echo ' </IfModule>' >> "$DIR/.htaccess"
echo '' >> "$DIR/.htaccess"
echo ' <IfModule !mod_filter.c>' >> "$DIR/.htaccess"
echo ' # Legacy versions of Apache' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE text/html text/plain text/css application/json' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE application/javascript' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE text/xml application/xml text/x-component' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml ' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE application/atom+xml' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject ' >> "$DIR/.htaccess"
echo ' AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype' >> "$DIR/.htaccess"
echo ' </IfModule>' >> "$DIR/.htaccess"
echo '</IfModule>' >> "$DIR/.htaccess"
fi
echo '<IfModule mod_rewrite.c>' >> "$DIR/.htaccess"
echo 'RewriteEngine On' >> "$DIR/.htaccess"
echo 'RewriteBase /' >> "$DIR/.htaccess"
if [ ! "$www" ]; then
if [ "$defaults" == "true" ]; then
www="without"
echo -e "Default is to not use www"
echo -e "To change, run with flag --with-www"
echo -e "For more options, run with flag --help\n"
else
echo -e "Would you like the primary version of the site to use wwws? [y/N] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ $input != 'y' ]]; then
www="without"
else
www="with"
fi
fi
fi
if [ ! "$domain" ]; then
echo -e "Please enter the domain without wwws, http or trailing slash \c"
read domain
fi
if [[ "$www" == "with" ]]; then
echo "#Primary Site will have wwws" >> "$DIR/.htaccess"
echo "RewriteCond %{HTTP_HOST} ^$domain [NC]" >> "$DIR/.htaccess"
echo "RewriteRule ^(.*)$ http://www.$domain/\$1 [L,R=301,NC]" >> "$DIR/.htaccess"
else
echo "#Primary site will not have wwws" >> "$DIR/.htaccess"
echo "RewriteCond %{HTTP_HOST} ^www.$domain [NC]" >> "$DIR/.htaccess"
echo "RewriteRule ^(.*)$ http://$domain/\$1 [L,R=301]" >> "$DIR/.htaccess"
fi
if [ ! "$uploads" ]; then
if [ "$defaults" == "true" ]; then
echo -e "By default, the uploads folder will be used as normal"
echo -e "To change, run with flag uploads [url]"
echo -e "For more options, run with flag --help\n"
else
echo "Aquarius Go now has the ability to redirect an uploads folder to a different"
echo "This is usefull for dev sites or local copies of sites"
echo "In order to use it, enter the url with the http(s):// and a trailing slash"
echo "Don't enter anything if you want to use the default location"
echo -e "URL: \c"
read uploads
fi
fi
if [ "$uploads" ]; then
echo 'RewriteCond %{REQUEST_FILENAME} !-d' >> "$DIR/.htaccess"
echo 'RewriteCond %{REQUEST_FILENAME} !-f' >> "$DIR/.htaccess"
echo 'RewriteRule wp-content/uploads/(.*) \' >> "$DIR/.htaccess"
echo " $uploads\$1 [NC,L]" >> "$DIR/.htaccess"
fi
echo 'RewriteRule ^index\.php$ - [L]' >> "$DIR/.htaccess"
echo 'RewriteCond %{REQUEST_FILENAME} !-f' >> "$DIR/.htaccess"
echo 'RewriteCond %{REQUEST_FILENAME} !-d' >> "$DIR/.htaccess"
echo 'RewriteRule . /index.php [L]' >> "$DIR/.htaccess"
echo '</IfModule>' >> "$DIR/.htaccess"

View file

@ -0,0 +1,209 @@
#!/bin/bash
# default to adding plugins
remove=false
# default to https plugins
ssh=true
# Cd to public html foder
cd ${PWD%/public_html*}/public_html
function doWebpack(){
line="$1:\t{path: path.resolve(plugins,'aquarius-$1')},"
sed -i "/const aquariusPlugins/a $line" webpack/variables.js
}
# Loop through arguments passed
while test $# -gt 0; do
case "$1" in
-h|--help)
#Print help message
echo -e "Aquarius Plugin installer"
echo -e "Adds submodules for commonly used plugins"
echo -e "You can string multiple plugins together"
echo -e "e.g. aquarius-plugin blocks clients"
echo ""
echo -e "-h, --help \t\t\t\t Show this help text"
echo -e "-r, --remove \t\t\t\t Remove any plugins after this flag"
echo -e "-s, --ssh \t\t\t\t Adds the ssh version for the submodule url"
echo ""
echo -e "blocks, aquarius-blocks \t\t install aquarius blocks"
echo -e "clients, aquarius-clients \t\t install aquarius clients"
echo -e "locations, aquarius-locations \t\t install aquarius locations"
echo -e "news, aquarius-news \t\t\t install aquarius news"
echo -e "people, aquarius-people \t\t install aquarius people"
echo -e "permissions, aquarius-permissions \t install aquarius permissions into mu-plugins"
echo -e "slider, aquarius-slider \t\t install aquarius slider"
echo -e "snippets, aquarius-snippets \t\t install aquarius snippets"
echo -e "widgets, aquarius-widgets \t\t install aquarius widgets"
exit 0
;;
-r|--remove)
#start removing
remove=true
shift
;;
-s|--ssh)
ssh=true
shift
;;
--no-ssh)
ssh=false
shift
;;
aquarius-blocks|blocks)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-blocks
git-delete-submodule "wp-content/plugins/aquarius-blocks"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-blocks.git wp-content/plugins/aquarius-blocks
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-blocks.git wp-content/plugins/aquarius-blocks
fi
npm install --save wp-content/plugins/aquarius-blocks
doWebpack blocks
fi
shift
;;
aquarius-clients|clients)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-clients
git-delete-submodule "wp-content/plugins/aquarius-clients"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-clients.git wp-content/plugins/aquarius-clients
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-clients.git wp-content/plugins/aquarius-clients
fi
npm install --save wp-content/plugins/aquarius-clients
doWebpack clients
fi
shift
;;
aquarius-locations|locations)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-locations
git-delete-submodule "wp-content/plugins/aquarius-locations"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-locations.git wp-content/plugins/aquarius-locations
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-locations.git wp-content/plugins/aquarius-locations
fi
npm install --save wp-content/plugins/aquarius-locations
doWebpack locations
fi
shift
;;
aquarius-news|news)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-news
git-delete-submodule "wp-content/plugins/aquarius-news"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-news.git wp-content/plugins/aquarius-news
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-news.git wp-content/plugins/aquarius-news
fi
npm install --save wp-content/plugins/aquarius-news
doWebpack news
fi
shift
;;
aquarius-people|people)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-people
git-delete-submodule "wp-content/plugins/aquarius-people"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-people.git wp-content/plugins/aquarius-people
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-people.git wp-content/plugins/aquarius-people
fi
npm install --save wp-content/plugins/aquarius-people
doWebpack people
fi
shift
;;
aquarius-permissions|permissions)
if [ "$remove" = true ]; then
npm remove wp-content/mu-plugins/aquarius-permissions
git-delete-submodule "wp-content/mu-plugins/aquarius-permissions"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-permissions.git wp-content/mu-plugins/aquarius-permissions
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-permissions.git wp-content/mu-plugins/aquarius-permissions
fi
npm install --save wp-content/mu-plugins/aquarius-permissions
fi
shift
;;
aquarius-projects|projects)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-slider
git-delete-submodule "wp-content/plugins/aquarius-projects"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-projects.git wp-content/plugins/aquarius-projects
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-projects.git wp-content/plugins/aquarius-projects
fi
npm install --save wp-content/plugins/aquarius-projects
doWebpack projects
fi
shift
;;
aquarius-slider|slider)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-slider
git-delete-submodule "wp-content/plugins/aquarius-slider"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-slider.git wp-content/plugins/aquarius-slider
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-slider.git wp-content/plugins/aquarius-slider
fi
npm install --save wp-content/plugins/aquarius-slider
fi
shift
;;
aquarius-snippets|snippets)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-snippets
git-delete-submodule "wp-content/plugins/aquarius-snippets"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-snippets.git wp-content/plugins/aquarius-snippets
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-snippets.git wp-content/plugins/aquarius-snippets
fi
npm install --save wp-content/plugins/aquarius-snippets
doWebpack snippets
fi
shift
;;
aquarius-widgets|widgets)
if [ "$remove" = true ]; then
npm remove wp-content/plugins/aquarius-widgets
git-delete-submodule "wp-content/plugins/aquarius-widgets"
else
if [ "$ssh" = true ]; then
git submodule add git@bitbucket.org:fellowshipproductionsltd/aquarius-widgets.git wp-content/plugins/aquarius-widgets
else
git submodule add https://bitbucket.org/fellowshipproductionsltd/aquarius-widgets.git wp-content/plugins/aquarius-widgets
fi
npm install --save wp-content/plugins/aquarius-widgets
doWebpack widgets
fi
shift
;;
*)
echo "Unknown plugin $1"
exit 0
;;
esac
done

View file

@ -0,0 +1,247 @@
#!/usr/bin/node
let fs = require('fs'),
path = require('path'),
args = process.argv.slice(2),
input = "-", // - will reperesent stdin
output = "-", // - will represent stdout
delimiter = ",";
let Reset = "\x1b[0m",
Bright = "\x1b[1m",
Dim = "\x1b[2m",
Underscore = "\x1b[4m",
Blink = "\x1b[5m",
Reverse = "\x1b[7m",
Hidden = "\x1b[8m",
FgBlack = "\x1b[30m",
FgRed = "\x1b[31m",
FgGreen = "\x1b[32m",
FgYellow = "\x1b[33m",
FgBlue = "\x1b[34m",
FgMagenta = "\x1b[35m",
FgCyan = "\x1b[36m",
FgWhite = "\x1b[37m",
BgBlack = "\x1b[40m",
BgRed = "\x1b[41m",
BgGreen = "\x1b[42m",
BgYellow = "\x1b[43m",
BgBlue = "\x1b[44m",
BgMagenta = "\x1b[45m",
BgCyan = "\x1b[46m",
BgWhite = "\x1b[47m";
if( args[0] == "-h" || args[0] == "--help" ){
console.log(FgGreen + "Aquarius Redirects (beta)" + Reset);
console.log();
console.log("This takes a csv file from stdinput or a given filename as the first parameter");
console.log();
console.log(FgGreen + "Example:" + Reset);
console.log("aquarius-redirects test.csv \t\t\t This will take each line of a csv file and turn it into a redirect");
console.log("cat test.csv | aquarius-redirects\t\t This is equivilent to the above");
console.log("echo \"/test/, /test-2/\" | aquarius-redirects\t This will create a redirect from /test/ to /test-2/");
console.log();
console.log();
console.log();
console.log(FgGreen + "The CSV File" + Reset);
console.log();
console.log("Each row in the CSV file should respond to a redirect.");
console.log("\t 1. From URL");
console.log("\t 2. To URL");
console.log("\t 3. Redirect Type");
console.log("\t 4. Exact ");
console.log();
console.log(FgGreen + "E.g." + Reset);
console.log("/page-1/ | /page-2/ | | ");
console.log("/about-us/meet-the-team/ | /meet-the-team/ | | ");
console.log("/about-us/meet-the-team/*/ | /meet-the-team/*/ | | true ");
console.log("//google.com/page-1/ | /page-2/ | | ");
console.log("//google.com/page-1/ | //google.co.uk/page-2/ | 302 | true ");
console.log("//google.com/*/ | //google.co.uk/*/ | | ");
console.log();
console.log(FgGreen + "From URL" + Reset);
console.log("This is the URL that should be redirected away from");
console.log("It can optionally contain a * symbol do denote a wildcard expresion");
console.log("For exmaple, /about-us/*/ will redirect from any child page of /about-us/");
console.log("");
console.log(FgGreen + "To URL" + Reset);
console.log("This is the URL that should be redirected to");
console.log("It can optionally contain an * symbol if you contained one in the From URL");
console.log("For exmaple, /about-us/*/ in From and /about/*/ in To will redirect all child pages of about us to the corresponding page under about");
console.log("");
console.log(FgGreen + "Redirect Type" + Reset);
console.log("This is the redirect type");
console.log("This is optional and contains the responce code that will be sent with the redirection request.");
console.log("The default is 301 which is a permenant redirect. You might want to make this 302 which implies a temporary redirect");
console.log("");
console.log(FgGreen + "Exact" + Reset);
console.log("This denotes whether the trailing slash should be optional on the from URL");
console.log("This defualts to false");
console.log("If true, the From url /about-us != /about-us/ ");
process.exit(0);
}
if(args[0] != undefined && args[0] != ""){
input = args[0];
}
if(input == "-" ) { // We are reading from stdin
process.stdin.setEncoding('utf-8');
let contents = "";
process.stdin.on("readable", () => {
let back = process.stdin.read();
if (back != null){
contents = contents + back;
}
});
process.stdin.on("end", () => {
doRedirects(contents);
});
//console.error("I haven't implemented stdin yet");
//process.exit(1);
} else {
fs.readFile(input, {encoding: 'utf-8'}, function(err,data){
if (!err) {
doRedirects(data)
} else {
console.log(err);
process.exit(1);
}
});
}
function doRedirects(data){
let lines = data.split("\n");
for (let i = 0; i < lines.length; i++){
lines[i] = lines[i].split(",");
for (let j = 0; j < lines[i].length; j++){
lines[i][j] = lines[i][j].replace(/^\s*/g,"");
lines[i][j] = lines[i][j].replace(/\s*$/g,"");
}
if (lines[i].length > 1){
let from = lines[i][0],
to = lines[i][1],
type = lines[i][2] || 301,
exact = lines[i][3] || false;
if( from == to ){
process.stdout.write("### No need to redirect " + from + "to itself ###\n\n");
continue;
}
let redirect = individualRedirect(from,to,type,exact);
process.stdout.write("###Redirect from "+from+" to "+to+"###\n");
process.stdout.write(redirect+"\n");
process.stdout.write("\n");
}
}
}
function individualRedirect(from, to, type, exact){
var ret = "";
if(!from){
throw new Error( "You must have a from url" );
}
if(!to){
throw new Error( "You must have a to url" );
}
if(!type){
type = 301;
}
if(!exact){
exact = false;
}
if(typeof exact == "string" && exact.toLowerCase() != "true"){
exact = false;
}
from = splitURL_(from);
if(from.domain != ""){
ret += "RewriteCond %{HTTP_HOST} ^" + escape_(from.domain) + "$\n";
}
for (var i in from.queries){
ret += "RewriteCond %{QUERY_STRING} (^|&)" + i + ((from.queries[i] !== undefined)?("\=" + from.queries[i]):"") + "($|&)\n";
}
ret += "RewriteRule " + doFrom_(from.path,exact) + " " + doTo_(to) + " " + doRewrite_(type);
return ret;
}
function doFrom_(from,exact){
if(from[0]=="/"){
from = "^" + from.substring(1,from.length);
}
if(!exact){
if(from[from.length-1]=="/"){
from = from+"?";
} else {
from = from + "\/?";
}
}
from = escape_(from);
return from + "$";
}
function escape_(url){
return url.replace(/\//g,"\\\/")
.replace(/\-/g,"\\\-")
.replace(/\./g,"\\\.")
.replace(/\*/g,"(.*?)");
}
function doTo_(to){
if(to[0]!="/" && to.indexOf("//")==-1){
to = "/"+to;
}
to = to.replace(/\*/g,"$1");
if(to.indexOf(" ") != -1){
to = '"' + to + '"';
}
return to;
}
function doRewrite_(type){
return "[L,R="+type+"]";
}
function splitURL_(url){
ret = {
protocol:"",
domain:"",
path:"",
queries:{}
};
var p=url.indexOf("//");
if(p!=-1){
//Gets the protocol
ret.protocol = url.substring(0,p-1);
//Removes up to and including the protocol
url = url.substring(p+2)
var d = url.indexOf("/");
if(d!=-1){
//gets the domain
ret.domain = url.substring(0,d);
url=url.substring(d);
} else {
ret.domain = url;
url = "";
}
}
var q=url.indexOf("?");
if(q!=-1){
queries = url.substring(q+1).split("&");
for (var i = 0; i<queries.length; i++){
ret.queries[queries[i].split("=")[0]] = queries[i].split("=")[1];
}
url = url.substring(0,q);
}
ret.path=url;
return ret;
}

View file

@ -0,0 +1,82 @@
#!/bin/bash
DIR="$PWD"
#Defaults
if [ -f "$DIR/wp-config.php" ]; then
echo -e "The file wp-config.php already exists."
echo -e "What do you want to do? [ b=Create Backup | o=Overwrite | a=Abort] \c"
read choice
choice=$(echo -e $choice | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ "$choice" == "b" ]]; then
name="wp-config.php.backup$(date +'%y:%m:%d:%T')"
mv "$DIR/wp-config.php" "$DIR/$name"
echo -e "Would you like to add this new file to .gitignore? [Y/n] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [[ $input != 'n' ]];then
echo "$name" >> .gitignore
fi
fi
if [[ "$choice" == "a" ]]; then
echo -e "Aborted by user"
return 1
fi
fi
if [ ! -f "$DIR/wp-config-sample.php" ]; then
echo "File not found!"
echo "Downloading sample"
curl "https://raw.githubusercontent.com/WordPress/WordPress/master/wp-config-sample.php" -o wp-config.php
fi
cp wp-config-sample.php wp-config.php
echo "Downloading Salts"
curl "https://api.wordpress.org/secret-key/1.1/salt/" -sSo salts
csplit wp-config.php '/AUTH_KEY/' '/NONCE_SALT/+1'
cat xx00 salts xx02 | tr -d '\r' > wp-config.php
rm salts xx00 xx01 xx02
echo -e "Please enter the database name \c"
read DBNAME
wp config set 'DB_NAME' "$DBNAME" > /dev/null
wp config set 'DB_USER' "root" > /dev/null
wp config set 'DB_PASSWORD' "root" > /dev/null
wp config set 'DB_HOST' "localhost" > /dev/null
wp config set 'JQUERY' "/wp-includes/js/jquery/jquery.js" --type=constant > /dev/null
echo -e "Would you like to have debug on? [y/N] \c"
read input
input=$(echo -e $input | tr '[:upper:]' '[:lower:]' | head -c 1)
if [ "$input" == "y" ]; then
debug=true
else
debug=false
fi
if [[ "$debug" == "true" ]] ; then
wp config set 'WP_DEBUG' 'true' --raw --type=constant > /dev/null
wp config set 'SAVEQUERIES' 'true' --raw --type=constant > /dev/null
else
wp config set 'WP_DEBUG' 'false' --raw --type=constant > /dev/null
wp config set 'SAVEQUERIES' 'false' --raw --type=constant > /dev/null
fi
# If wordpress is installed in a sub-directory, add redirects
#if [[ "$subdirectory" == "true" ]]; then
# echo "define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );" >> "$DIR/wp-config.php"
# echo "define( 'WP_CONTENT_URL', 'http://' . \$_SERVER['HTTP_HOST'] . '/wp-content' );" >> "$DIR/wp-config.php"
#fi
#echo "if ( !defined('ABSPATH') )" >> "$DIR/wp-config.php"
#echo " define('ABSPATH',dirname(__FILE__) . '/'); " >> "$DIR/wp-config.php"
#
#echo "require_once(ABSPATH . 'wp-settings.php');" >> "$DIR/wp-config.php"
#

View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# A bash script to replace a local database with one on a server
# It relies on wp being installed on both the server and the local machine
# - Note, if using xampp, mamp .. you should make sure that mysql and php are
# both in your $PATH
# On your local machine, it assumes that WP is in a folder called public_html
# SSH entry from .ssh/config
sshKey="$1"
# The folder so search for on the remote server
# the home folder is grepped for this so public should get public/ and public_html/
sshFolder="${2:-public}"
# If the ssh entry isn't given, exit with a warning
if [ -z "$sshKey" ]; then
echo "Add an SSH entry"
exit 1
fi
# This command exits with a non-zero exit code if not a multisite
wp site list 2>/dev/null >/dev/null
if [ $? -eq 0 ]; then
multisite="true"
else
multisite="false"
fi
# Finds the local public_html folder
public_html="${PWD%/public_html*}/public_html"
# Gets the folder that we should Copy from
sshFolder="$(ssh "$sshKey" ls | grep "$sshFolder")"
# gets the fell path of the folder for the path replace later on
sshFolderPath="$(ssh "$sshKey" "cd $sshFolder; pwd")"
if [ "$multisite" == "true" ]; then
# Gets an array of domains on the remote server
remoteDomains=($(ssh "$sshKey" "cd $sshFolder; wp site list 2> /dev/null" | cut -f 2 | tail -n +2 | sed -E "s/https?:\/\///g" | sed -E "s/\/$//g"))
# Gets an array of domains on the local server
localDomains=($(wp site list 2> /dev/null | cut -f 2 | tail -n +2 | sed -E "s/https?:\/\///g" | sed -E "s/\/$//g"))
else
# puts the site url in an array
remoteDomains=($(ssh "$sshKey" "cd $sshFolder; wp option get siteurl 2> /dev/null" | sed -E "s/https?:\/\///g" | sed -E "s/\/$//g"))
# Gets an array of domains on the local server
localDomains=($(wp option get siteurl 2> /dev/null | sed -E "s/https?:\/\///g" | sed -E "s/\/$//g"))
fi
echo "Downloading database"
# Dumps the database into our public_html folder
ssh "$sshKey" "cd $sshFolder; wp db export -" > "$public_html"/db.dump
# Imports the new database
wp db import "$public_html"/db.dump 2> /dev/null > /dev/null
# Loops through the domains and does a search and replace
for (( i = 0; i < ${#remoteDomains[@]}; i++ )); do
echo "${remoteDomains[$i]} -> ${localDomains[$i]}"
wp search-replace --all-tables --url="${remoteDomains[$i]}" "${remoteDomains[$i]}" "${localDomains[$i]}" 2> /dev/null > /dev/null
done
# Searches and replaces the paths
echo "$sshFolderPath -> $public_html"
wp search-replace --all-tables --url="${localDomains[0]}" "$sshFolderPath" "$public_html" 2> /dev/null > /dev/null
# Removes the db.dump that we created
rm "$public_html"/db.dump
#Makes sure everything in the uploads folder on the server is also on the local
rsync -ruh --progress "${sshKey}:${sshFolder}/wp-content/uploads/" "${public_html}/wp-content/uploads"

52
bin/.bin/wordpress/getthemepath Executable file
View file

@ -0,0 +1,52 @@
#!/usr/bin/env zsh
# Small script that echos the path of a wordpress theme
#
# By default it will echo the path of the active theme. If an argument is given, it will grep the list of themes with the argment and return the path for the first
#
# It assumes that the wordpress is in a folder called public_html or public_html/wp. It should be run from inside this directory
#
# It can also be run inside a wiki directory if public_html is a sibling of wiki
#
# @author jab2870
# @requires wp
# Gets the public html folder from any sub folder or the wiki folder
public_html="${${PWD%/public_html*}%/wiki*}/public_html"
# Checks the public_html directory exists
if [ -d $public_html ]; then
# Checks to see if wp is in a subdirectory called wp
if [ -d $public_html/wp ]; then
wpPath=$public_html/wp;
else
wpPath=$public_html;
fi
# This assumes the domain for the site. It should be changed according to your setup
# It assumes here that the domain is the same as public_html folder with .local.jh appended
# This is needed if using a multisite setup
domain="$(basename $(dirname $public_html ) ).local.jh"
# If we have an argument
if [ ! -z "$1" ]; then
# Try and find the theme containing the argument and return it's path
theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "$1" | head -n 1 | awk '{print $1}') 2> /dev/null ))
else
# Otherwise, get the active plugin
theme=$(dirname $(wp --path="$wpPath" --url="$domain" theme path $(wp --path="$wpPath" --url="$domain" theme list 2> /dev/null | grep "active" | grep -v "inactive" | awk '{print $1}') 2> /dev/null ))
fi
# If we have an answer
if [ -d $theme ]; then
# Echo it
echo $theme
else
# Otherwise we can fail
>&2 echo "cannot find theme"
exit 2
fi
else
>&2 echo "Cannot find public_html"
exit 1
fi

View file

@ -0,0 +1,9 @@
#!/usr/bin/bash
pluginFolder="/home/jonathan/WPPlugins"
for dir in $pluginFolder/*/; do
cd $dir
name=${PWD##*/}
echo $name | toilet -w 200
/home/jonathan/.gem/ruby/2.4.0/bin/git-svn-mirror update
done

11
bin/.bin/wordpress/updatePlugin Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/sh
if [ -n "$1" ]; then
plugin=$(wp plugin list 2> /dev/null | grep available | grep $1 | head -n 1 | awk '{print $1}')
else
plugin=$(wp plugin list 2> /dev/null | grep available | head -n 1 | awk '{print $1}')
fi
echo "$plugin"
versions=$(wp plugin update $plugin 2> /dev/null | tail -n 2 | head -n 1 | awk '{print $2 "->" $3}')
echo "$versions"
git add .
git commit -m "Update $plugin $versions"

10
bin/.bin/wordpress/wpLookup Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env sh
folder="$HOME/.local/share/Zeal/Zeal/docsets/WordPress.docset/Contents/Resources/Documents/developer.wordpress.org/reference/"
file=$(find "$folder" -name "index.html" -not -path "*/page/*" -not -path "*/since/*" |
awk -F '/' '{print "(" $(NF-2) ") " $(NF-1)}' |
rofi -dmenu |
tr -d '()' |
awk '{print $1 "/" $2 "/index.html"}')
#file=$(find "$folder" -name "index.html" -not -path "*/methods/*" )
#echo "$file"
echo "$folder$file" | xargs qutebrowser

54
bin/.bin/wordpress/wp_urls Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env zsh
function get_children(){
local parentid=${1:-0}
local depth=${2:-0}
wp --url="$domain" --post_type="$post_type" --post_parent="$parentid" --format="csv" post list | tail -n +2 | sort | while read line; do
newid=$(echo "$line" | awk -F ',' '{print $1}')
pagename=$(echo "$line" | awk -F ',' '{print $2}')
slug=$(echo "$line" | awk -F ',' '{print $3}')
echo -n "$pagename$seperator" | tr -d '"'
for i in $(seq 0 $depth); do
echo -n "$seperator"
done
echo "$slug/"
get_children "$newid" "$((depth+1))"
done
}
seperator="§"
public_html="${${PWD%/public_html*}%/wiki*}/public_html"
if [ -d $public_html ]
then
if [ -d $public_html/wp ]
then
wpPath=$public_html/wp
else
wpPath=$public_html
fi
domain="$(basename $(dirname $public_html ) ).local.jh"
post_type="post"
while [[ $# -gt 0 ]]; do
case "$1" in
"--domain")
domain="$2"
shift
shift
;;
"--post_type")
post_type="$2"
shift
shift
;;
esac
done
get_children
fi