diff --git a/README.md b/README.md index 88d0b5e..cb8c555 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ yarn Upload all changes in storage folder into git repository ### submodule_pull - +Update git submodules ## 📁 File system diff --git a/package.json b/package.json index 257e968..17afa60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sscripts", - "version": "1.0.7", + "version": "1.0.8", "description": "Useful Shell scripts for projects", "author": "sHa ", "license": "MIT", @@ -15,6 +15,7 @@ "hello.sh": "./scripts/hello.sh", "hello.js": "./scripts/hello.js", "git.storage_push": "./scripts/git/storage_push.sh", + "git.submodule_pull": "./scripts/git/submodule_pull.sh", "fs.fix_permissions": "./scripts/fs/fix_permissions.sh", "docker.up": "./scripts/docker/up.sh", "docker.down": "./scripts/docker/down.sh", diff --git a/scripts/git/storage_push.sh b/scripts/git/storage_push.sh index b4a32f2..d6b4f08 100755 --- a/scripts/git/storage_push.sh +++ b/scripts/git/storage_push.sh @@ -28,4 +28,12 @@ cd $PROJECT/storage git add . --all && git commit -m "storage" -git push origin master --force + +if [ -f $PROJECT/docker/.ssh/id_rsa ]; then + if [ `stat -c %a $PROJECT/docker/.ssh/id_rsa` -ne '600' ]; then + chmod -R a=rwX,go-rwX $PROJECT/docker/.ssh + fi + ssh-agent sh -c "ssh-add -D; ssh-add $PROJECT/docker/.ssh/id_rsa; git push origin master --force" +else + git push origin master --force +fi diff --git a/scripts/git/submodule_pull.sh b/scripts/git/submodule_pull.sh index 4297a33..4526d68 100755 --- a/scripts/git/submodule_pull.sh +++ b/scripts/git/submodule_pull.sh @@ -7,10 +7,23 @@ # @link https://shadoll.dev # -DIR=$(dirname "$0") -ROOT=$(cd "$DIR"/.. && pwd) +DIR=$(dirname $BASH_SOURCE) +PROJECT=(${DIR//node_modules/ }) -chmod -R a=rwX,go-rwX "$ROOT"/docker/.ssh/ +git --version 2>&1 >/dev/null +GIT_IS_AVAILABLE=$? +if [ $GIT_IS_AVAILABLE -ne 0 ]; then + echo "ERROR: The program 'git' is currently not installed." + echo "Try: 'sudo apt install git' to install it" + exit 1 +fi git submodule init -ssh-agent sh -c "ssh-add -D; ssh-add $ROOT/docker/.ssh/id_rsa; git submodule update" +if [ -f $PROJECT/docker/.ssh/id_rsa ]; then + if [ `stat -c %a $PROJECT/docker/.ssh/id_rsa` -ne '600' ]; then + chmod -R a=rwX,go-rwX $PROJECT/docker/.ssh + fi + ssh-agent sh -c "ssh-add -D; ssh-add $ROOT/docker/.ssh/id_rsa; git submodule update" +else + git submodule update +fi