Skip to content

Commit

Permalink
A bunch of .sh scripts misc utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Mar 15, 2018
1 parent f565571 commit 26ce544
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 3 deletions.
3 changes: 0 additions & 3 deletions cleanup_pyc.sh

This file was deleted.

4 changes: 4 additions & 0 deletions flake8.sh
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

flake8 geonode
17 changes: 17 additions & 0 deletions scripts/misc/align_remote_branches.sh
@@ -0,0 +1,17 @@
#!/bin/bash

# This is the script directory
# pushd $(dirname $0)

# This is the current directory
pushd $PWD

git fetch --all --prune
OUTPUT=`git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv) | awk '{print $1}' | xargs git branch -D 2>&1`

`echo $OUTPUT | grep 'branch name required' &> /dev/null`
if [ $? == 0 ]; then
echo "All remote branches are aligned!"
BRANCH=`git branch 2>&1`
echo "You are currently on branch: $BRANCH"
fi
9 changes: 9 additions & 0 deletions scripts/misc/cleanup_pyc.sh
@@ -0,0 +1,9 @@
#!/bin/bash

# This is the script directory
# pushd $(dirname $0)

# This is the current directory
pushd $PWD

find . -name "*.pyc" -exec rm -f {} \;
28 changes: 28 additions & 0 deletions scripts/misc/django_backup.sh
@@ -0,0 +1,28 @@
#!/bin/bash

source ~/.virtualenvs/geonode/bin/activate

# This is the script directory
# pushd $(dirname $0)

# This is the current directory
pushd $PWD

case $1 in
"backup-dir")
case $2 in
"")
echo "Missing 'backup-dir <backup-dis>' path!"
;;
*)
echo "Starting Backup to $2"
DJANGO_SETTINGS_MODULE=geonode.settings python -W ignore manage.py backup --backup-dir=$2
;;
esac
;;
*)
echo "Missing 'backup-dir' parameter!"
;;
esac

exit 0
11 changes: 11 additions & 0 deletions scripts/misc/django_generate_secret_key.sh
@@ -0,0 +1,11 @@
#!/bin/bash

# This is the script directory
# pushd $(dirname $0)

# This is the current directory
pushd $PWD

OUTPUT=`python -c "import random,string;print(''.join([random.SystemRandom().choice(\"{}{}{}\".format(string.ascii_letters, string.digits, \"---\")) for i in range(63)]).replace('\\'','\\'\"\\'\"\\''))"; 2>&1`

echo $OUTPUT
30 changes: 30 additions & 0 deletions scripts/misc/django_restore.sh
@@ -0,0 +1,30 @@
#!/bin/bash

source ~/.virtualenvs/geonode/bin/activate

# This is the script directory
# pushd $(dirname $0)

# This is the current directory
pushd $PWD

case $1 in
"backup-file")
case $2 in
"")
echo "Missing 'backup-file <backup-file>' path!"
;;
*)
echo "Starting Restore from $2"
DJANGO_SETTINGS_MODULE=geonode.settings python -W ignore manage.py restore --backup-file=$2
# e.g.: source-address=localhost:8000 target-address=example.com
DJANGO_SETTINGS_MODULE=geonode.settings python -W ignore manage.py migrate_baseurl -f --source-address=source-address --target-address=target-address
;;
esac
;;
*)
echo "Missing 'backup-file' parameter!"
;;
esac

exit 0

0 comments on commit 26ce544

Please sign in to comment.