Add forcessl.sh
This commit is contained in:
31
forcessl.sh
Normal file
31
forcessl.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# set -x
|
||||
set -e
|
||||
|
||||
dir=~/.abra/recipes
|
||||
for r in `ls $dir`; do
|
||||
cd "$dir/$r"
|
||||
# check if recipe has SSLForceHost label
|
||||
# skip if it's a commented line
|
||||
# skip .swp binary file (found in radicale and I don't know what is it for)
|
||||
if res=$(grep -r "SSLForceHost" . 2>/dev/null \
|
||||
| grep -v "#-" | grep -v "# -" \
|
||||
| grep -v ".swp"); then
|
||||
branch=$(git branch --format '%(refname:short)' --list main master | head -n 1)
|
||||
current_dir="${PWD##*/}"
|
||||
git checkout $branch
|
||||
git pull --rebase
|
||||
yes | git branch -D forceSsl
|
||||
git checkout -b forceSsl
|
||||
for file in `echo $res | cut -d ":" -f 1`; do
|
||||
# I use macos and BSD versions of tools like sed look weird :(
|
||||
sed -i '' -e "s/headers.SSLForceHost=true/redirectscheme.scheme=https/" $file
|
||||
sed -i '' -e "s/headers.SSLHost=.*/redirectscheme.permanent=true\"/" $file
|
||||
done
|
||||
git add $file
|
||||
git commit -m "[mass update] fix supporting multiple domains while enforcing ssl"
|
||||
git push --set-upstream origin forceSsl
|
||||
echo "https://git.coopcloud.tech/coop-cloud/$current_dir/pulls/new/forceSsl"
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user