Skip to content

Instantly share code, notes, and snippets.

@Anthonykung
Last active January 16, 2021 06:04
Show Gist options
  • Save Anthonykung/46c48ea7ac48bf42165404cdbc185661 to your computer and use it in GitHub Desktop.
Save Anthonykung/46c48ea7ac48bf42165404cdbc185661 to your computer and use it in GitHub Desktop.
Anthonian Permission Repairer - Repair broken permissions for Anthonian Node.js projects
#!/bin/sh
##########################################################
# Name: Anthonian Permission Repairer #
# Description: Repair broken permissions for Anthonian #
# Node.js projects #
# Download: wget https://gist.anth.dev/fs/apr.sh #
# Usage: sh apr.sh {{ REPLACE WITH DIRECTORY PATH }} #
# Example: sh apr.sh ./ #
# Date: November 1st, 2020 #
# Created with <3 by Anthony Kung #
# Author URI: https://anth.dev #
# License: Apache 2.0 (See docs/LICENSE.md for details) #
##########################################################
echo "\033[94m>_ APR: Fixing Directories Ownership...";
find $1 -type d -exec chown $USER {} \;
echo "\033[92m>_ APR: Directories Ownership Fixed";
echo "\033[94m>_ APR: Fixing Directories Permission...";
find $1 -type d -exec chmod 755 {} \;
echo "\033[92m>_ APR: Directories Permission Fixed\033[0m\n";
echo "\033[94m>_ APR: Fixing Files Ownership...";
find $1 -type d -exec chown $USER {} \;
echo "\033[92m>_ APR: Files Ownership Fixed";
echo "\033[94m>_ APR: Fixing Files Permission...";
find $1 -type f -exec chmod 644 {} \;
echo "\033[92m>_ APR: Files Permission Fixed\033[0m\n";
# For Anthonian Projects Directories Only
echo "\033[94m>_ APR: Setting Executables Permission...";
chmod 755 ./apr.sh;
# chmod 755 ./acli.js;
echo "\033[92m>_ APR: Executables Permission Set\033[0m\n";
echo "\033[92m>_ APR: All Permissions Fixed\033[0m";
echo "\033[92m>_ APR: Verifying Permissions...\033[0m";
stat -c "%a %n" $1*;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment