Scripts that I use for my day to day work.
Changes the author of the git log, use with caution. To use it follow these steps:
- Edit <OLD_EMAIL_HERE> with the old email you want to replace (line 5 of the script).
- Edit <CORRECT_NAME_HERE> with the new name you want to put in the git logs (line 6 of the script).
- Edit <CORRECT_EMAIL_HERE> with the new email you want to put in the git logs (line 7 of the script).
PREREQUISITES: You need to install jq
and curl
in your machine before executing this script.
This script could be used to store a file in google drive, use it along with a cronjob in your server and you will have automatic backups. Before you can use it please follow these steps:
- Create a gmail account if you don't have any.
- Go to Google API Console (search it in google if you can't find it).
- Create a project.
- Click on 'Enable API or Service'.
- Search for 'Google Drive API'.
- Click on 'Enable'.
- Go to 'OAuth consent screen' and click on 'External' and then in 'Create'.
- Fill only the required information requested (App name, User support email, etc...).
- In the next step, you don't need to add any scopes.
- In the next step, add your gmail as test user.
- You will see a summary, check that everything is ok.
- Go to 'Credentials'.
- Click on 'Create Credentials' and then in 'OAuth client ID'.
- Select 'Desktop app' as Application type and put it a name (e.g. 'My backups CLI').
- After this, you will see a modal with 'Your Client ID' and 'Your Client Secret', please copy them and put in a temporal file in your pc.
- Open gdrive_backup.sh and copy
BROWSER_URL
into your browser, please replace${G_CLIENT_ID}
in the URL with 'Your Client ID' before opening it in the browser. - Select your gmail account and follow the steps, be aware that you will be warned about a 'Testing' application. At the end of this process you will receive an AUTHORIZATION_CODE, please copy it and paste it into your pc.
- Open gdrive_backup.sh and edit
G_CLIENT_ID
with 'Your Client ID',G_CLIENT_SECRET
with 'Your Client Secret' andAUTHORIZATION_CODE
with your AUTHORIZATION_CODE. - Open a terminal and do the following:
curl -s --request POST --data "code=${AUTHORIZATION_CODE}&client_id=${G_CLIENT_ID}&client_secret=${G_CLIENT_SECRET}&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" https://oauth2.googleapis.com/token
note that you have to replace ${} with your information, this will gives you a JSON response with arefresh_token
please copy and paste it in your pc. - Open gdrive_backup.sh and edit
REFRESH_TOKEN
with your refresh token of the previous step. - Remember to put your Google application in production, if you don't do this your refresh token will expire in 7 days. More info: https://stackoverflow.com/a/65936387
- Now you could use the script to upload files to Google Drive, enjoy!.
Scan an IP range and a port. Usage (for example to scan IP 192.168.1.0/24 and port 22):
./scanall 192.168.1 22