Initial commit
This commit is contained in:
71
Backup/automaticBackup.sh
Normal file
71
Backup/automaticBackup.sh
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# automaticBackup.sh
|
||||||
|
#
|
||||||
|
# Automatic, configurable, optional-SFTP backup script.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 VELENDEU, eetnaviation
|
||||||
|
#
|
||||||
|
# https://velend.eu/
|
||||||
|
# https://git.velend.eu/eetnaviation/shscripts
|
||||||
|
#
|
||||||
|
# All rights reserved unless otherwise stated.
|
||||||
|
#
|
||||||
|
# Permission is hereby denied to copy, modify, distribute, sublicense,
|
||||||
|
# or sell copies of this software without explicit prior written consent.
|
||||||
|
#
|
||||||
|
# All dependency trademarks and names if included are subject to copyright
|
||||||
|
# of their respective owners.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
##################### BEGIN USER CONFIGURABLE PART #####################
|
||||||
|
|
||||||
|
BACKUP_PATHS="" # Choose directories you want to backup separated by spaces. Example: Backup /home and /var/www would be "/home /var/www"
|
||||||
|
BACKUP_DESTINATION="/backup" # Default /backup, changes the backup destination. This is where your local backups are stored.
|
||||||
|
|
||||||
|
ENABLE_SFTP_BACKUP="false" # Default false, enables/disables SFTP backup sync.
|
||||||
|
DELETE_LOCAL_BACKUP_UPON_SUCCESSFUL_SFTP_UPLOAD="true" # Default true, enables/disables deleting local backup after successful upload to sftp server.
|
||||||
|
SFTP_USER="" # Enter your SFTP user here.
|
||||||
|
SFTP_HOST="" # Enter your SFTP server IP or domain name here.
|
||||||
|
SFTP_PASSWORD="" # Enter your SFTP user password here.
|
||||||
|
SFTP_REMOTE_DIRECTORY="" # Enter your SFTP remote directory here.
|
||||||
|
|
||||||
|
###################### END USER CONFIGURABLE PART ######################
|
||||||
|
|
||||||
|
DATE=$(date +%Y-%m-%d)
|
||||||
|
HOSTNAME=$(HOSTNAME -s)
|
||||||
|
ARCHIVE_FILE_NAME="$HOSTNAME-$DATE.tgz"
|
||||||
|
LOCAL_FILE="$BACKUP_DESTINATION/$ARCHIVE_FILE_NAME"
|
||||||
|
|
||||||
|
# Local backup part.
|
||||||
|
echo "Starting local backup..."
|
||||||
|
mkdir -p "$BACKUP_DESTINATION"
|
||||||
|
tar czf "$BACKUP_DESTINATION/$ARCHIVE_FILE_NAME" $BACKUP_PATHS
|
||||||
|
echo "Finished local backup!"
|
||||||
|
ls -aril "$BACKUP_DESTINATION"
|
||||||
|
|
||||||
|
# If enabled sync backup to SFTP server.
|
||||||
|
if [ "$ENABLE_SFTP_BACKUP" = "true" ]; then
|
||||||
|
lftp -u "$SFTP_USER,$SFTP_PASSWORD" sftp://$SFTP_HOST <<EOF
|
||||||
|
put "$LOCAL_FILE" -o "$SFTP_REMOTE_DIRECTORY/$(basename $LOCAL_FILE)"
|
||||||
|
quit
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Tell user SFTP sync is finished
|
||||||
|
echo "Uploaded backup to destination SFTP server."
|
||||||
|
|
||||||
|
# Delete local file to save space, this can be enabled or disabled with DELETE_LOCAL_BACKUP_UPON_SUCCESSFUL_SFTP_UPLOAD.
|
||||||
|
if [ "$DELETE_LOCAL_BACKUP_UPON_SUCCESSFUL_SFTP_UPLOAD" = "true" ]; then
|
||||||
|
rm -f "$BACKUP_DESTINATION/$ARCHIVE_FILE_NAME"
|
||||||
|
echo "Deleted local copy of backup successfully."
|
||||||
|
fi
|
33
Git/addGitSSHKey.sh
Normal file
33
Git/addGitSSHKey.sh
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# addGitSSHKey.sh
|
||||||
|
#
|
||||||
|
# Easily setup your GIT SSH key.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 VELENDEU, eetnaviation
|
||||||
|
#
|
||||||
|
# https://velend.eu/
|
||||||
|
# https://git.velend.eu/eetnaviation/shscripts
|
||||||
|
#
|
||||||
|
# All rights reserved unless otherwise stated.
|
||||||
|
#
|
||||||
|
# Permission is hereby denied to copy, modify, distribute, sublicense,
|
||||||
|
# or sell copies of this software without explicit prior written consent.
|
||||||
|
#
|
||||||
|
# All dependency trademarks and names if included are subject to copyright
|
||||||
|
# of their respective owners.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
GIT_SSH_KEY="" # Put your git ssh key file path here, for example /home/user/git-ssh-key
|
||||||
|
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add $GIT_SSH_KEY
|
41
IpTables/autoIpTables.sh
Normal file
41
IpTables/autoIpTables.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# autoIpTables.sh
|
||||||
|
#
|
||||||
|
# Setup multiple IpTables incoming and outgoing port mappings for easy setup.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 VELENDEU, eetnaviation
|
||||||
|
#
|
||||||
|
# https://velend.eu/
|
||||||
|
# https://git.velend.eu/eetnaviation/shscripts
|
||||||
|
#
|
||||||
|
# All rights reserved unless otherwise stated.
|
||||||
|
#
|
||||||
|
# Permission is hereby denied to copy, modify, distribute, sublicense,
|
||||||
|
# or sell copies of this software without explicit prior written consent.
|
||||||
|
#
|
||||||
|
# All dependency trademarks and names if included are subject to copyright
|
||||||
|
# of their respective owners.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
declare -A PORT_MAPS=( # Write your ports in here, example [80]=1234 would direct outside port 80 to inside port 1234
|
||||||
|
[80]=1234
|
||||||
|
)
|
||||||
|
|
||||||
|
# Apply iptables rule for each mapping
|
||||||
|
for outsidePort in "${!PORT_MAPS[@]}"; do
|
||||||
|
insidePort="${PORT_MAPS[$outsidePort]}"
|
||||||
|
iptables -t nat -A PREROUTING -p tcp --dport "$outsidePort" -j REDIRECT --to-port "$insidePort"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Display all mappings
|
||||||
|
iptables -t nat -L -v -n
|
44
IpTables/easyIpTables.sh
Normal file
44
IpTables/easyIpTables.sh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# easyIpTables.sh
|
||||||
|
#
|
||||||
|
# Allows you to easily set IpTables mappings for incoming and outgoing ports.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 VELENDEU, eetnaviation
|
||||||
|
#
|
||||||
|
# https://velend.eu/
|
||||||
|
# https://git.velend.eu/eetnaviation/shscripts
|
||||||
|
#
|
||||||
|
# All rights reserved unless otherwise stated.
|
||||||
|
#
|
||||||
|
# Permission is hereby denied to copy, modify, distribute, sublicense,
|
||||||
|
# or sell copies of this software without explicit prior written consent.
|
||||||
|
#
|
||||||
|
# All dependency trademarks and names if included are subject to copyright
|
||||||
|
# of their respective owners.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
# THE SOFTWARE.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo "easyIpTables.sh // (c) Copyright 2025 VELENDEU , eetnaviation // See source for more info."
|
||||||
|
echo "Press CTRL+C (^C) to quit."
|
||||||
|
read -p "Enter outside port: " outsidePort
|
||||||
|
read -p "Enter inside port: " insidePort
|
||||||
|
|
||||||
|
if [[ "$outsidePort" =~ ^[0-9]+$ && "$insidePort" =~ ^[0-9]+$ ]]; then
|
||||||
|
iptables -t nat -A PREROUTING -p tcp --dport "$outsidePort" -j REDIRECT --to-port "$insidePort"
|
||||||
|
echo "Redirected TCP $outsidePort -> $insidePort, Here are your current IpTables mappings:"
|
||||||
|
# Display all mappings
|
||||||
|
iptables -t nat -L -v -n
|
||||||
|
else
|
||||||
|
echo "Invalid input, must be numeric ports."
|
||||||
|
fi
|
||||||
|
done
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# shscripts
|
||||||
|
A useful collection of my bash/sh scripts.
|
||||||
|
|
||||||
|
## Script collection breakdown
|
||||||
|
Here is a breakdown of the collection.
|
||||||
|
### Backup scripts
|
||||||
|
Scripts to simplify backup procedures.
|
||||||
|
[automaticBackup.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/Backup/automaticBackup.sh) - Automatic, configurable, optional-SFTP backup script.
|
||||||
|
### IpTables scripts
|
||||||
|
Scripts to configure different IpTables aspects.
|
||||||
|
[easyIpTables.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/IpTables/easyIpTables.sh) - Allows you to easily set IpTables mappings for incoming and outgoing ports.
|
||||||
|
[autoIpTables.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/IpTables/autoIpTables.sh) - Setup multiple IpTables incoming and outgoing port mappings for easy setup.
|
||||||
|
### Git scripts
|
||||||
|
Scripts to automate or simplify procedures with GIT.
|
||||||
|
[addGitSSHKey.sh](https://git.velend.eu/eetnaviation/shscripts/src/branch/main/Git/addGitSSHKey.sh) - Simple script to add your GIT ssh key on startup or when executed.
|
Reference in New Issue
Block a user