diff --git a/fire_vpn.sh b/fire_vpn.sh new file mode 100755 index 0000000..31e899e --- /dev/null +++ b/fire_vpn.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +################################################################# +# Script to activate and deactivate a VPN connection. # +# # +# Author: Maximilian Stiefel # +# Last modified: 29. April 2017 # +# CLI usage: ./fire_vpn.sh up/down # +# Required PKGs: nmcli # +# # +################################################################# + +################################################################# +# Vars # +################################################################# +# UUID of connection +UUID="5a770ffe-db28-486e-842e-e41abd0c3d10" +# Expected number of parameters +NU_PARAMS=1; + +# Command to set up connection to VPN +MYCMD1="nmcli --ask connection $1 uuid $UUID" + +################################################################# +# Action # +################################################################# +# Check if the expected number of parameters is given. +if [ $# != $NU_PARAMS ] +then + echo "Error: Illegal number of parameters." + echo "Correct usage is:" + echo "./fire_vpn.sh up/down" + exit 1; +fi + +# Check what shall be done +if [ "$1" = "up" ] +then + echo "####################################################" + echo "Firing up VPN connection." + echo "####################################################" +elif [ "$1" = "down" ] +then + echo "####################################################" + echo "Closing down VPN connection." + echo "####################################################" +else + echo "####################################################" + echo "Retarded input argument." + echo "####################################################" + exit 1; +fi +echo "$MYCMD1" +$MYCMD1 +read -n1 -r -p "Waiting for termination. Press any key ... " key +exit 0; diff --git a/i3wm_cmd_wrapper.sh b/i3wm_cmd_wrapper.sh new file mode 100755 index 0000000..164f1cc --- /dev/null +++ b/i3wm_cmd_wrapper.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +################################################################# +# Wrapper for cmd line programs in the context of window # +# managers like i3wm (e.g. bash scripts). # +# # +# Author: Maximilian Stiefel # +# Last modified: 29. April 2017 # +# CLI usage: Put in autostart script (e.g. ~/.i3/config) # +# ./i3wm_cmd_wrapper.sh window_name # +# path_to_script # +# Required PKGs: xterm # +# # +################################################################# + +################################################################# +# Vars # +################################################################# +# Exctracting username@server.com +SCRIPT="$2" +# Extracting window name +WDW_NAME="$1" + +# Command to execute +MYCMD1="xterm -T $WDW_NAME -e \"$SCRIPT\"" +# Expected number of params +NU_PARAMS=2; + +################################################################# +# Action # +################################################################# +# Check if the expected number of parameters is given. +if [ $# != $NU_PARAMS ] +then + echo "Error: Illegal number of parameters." + echo "Correct usage is:" + echo "./i3wm_cmd_wrapper.sh window_name path_to_script" + exit 1; +fi +echo "$MYCMD1" +xterm -T $WDW_NAME -e "$SCRIPT" diff --git a/mount_enc.sh b/mount_enc.sh new file mode 100755 index 0000000..d73fdfd --- /dev/null +++ b/mount_enc.sh @@ -0,0 +1,91 @@ +#!/bin/sh + +################################################################# +# Mounting an extrenal device and mount an encrypted container # +# in it. # +# # +# Author: Maximilian Stiefel # +# Last modified: 23. April 2017 # +# CLI usage: ./mount_enc.sh # +# Required PKGs: encfs, sudo # +# # +################################################################# + +################################################################# +# Vars # +################################################################# +# Mountpoint for external drive +MOUNT_POINT="/media/sack/xxxx" +# Device identifier +DEVICE="/dev/sdc34" +# File system (-t option of mount) +FILE_SYSTEM="fat32" +# Encfs enrypted files location +ENC_LOC="$MOUNT_POINT/.sexy" +# Encfs mount point +ENC_MP="$MOUNT_POINT/sexy" +# Link to mount point +LINK="/home/sack/sssss" + +# Command to execute for mounting +MYCMD1="sudo mount -t $FILE_SYSTEM $DEVICE $MOUNT_POINT" +# Command to create a mount point if necessary +MYCMD2="mdkir $MOUNT_POINT" +# Command to check wether the device is already mounted +MYCMD3=$(mount | grep $DEVICE) +# Command to use encfs +MYCMD4="encfs $ENC_LOC $ENC_MP" +# Command to create link +MYCMD5="ln -s $MOUNT_POINT $LINK" + +################################################################# +# Action # +################################################################# +# Check if mount point does exist if not create +if [ ! -d "$MOUNT_POINT" ]; then + echo "####################################################" + echo "Creating directory $MOUNT_POINT" + echo "####################################################" + echo "$MYCMD2" + $MYCMD2 + echo +fi + +# Check if mounted already. Is string value set? +if [ ! -n "$MYCMD3" ] +then + echo "####################################################" + echo "Mounting external device $DEVICE" + echo "to $MOUNT_POINT." + echo "####################################################" + echo "$MYCMD1" + $MYCMD1 + echo +else + echo "####################################################" + echo "$DEVICE is already mounted." + echo "####################################################" + echo +fi + +# Use encfs to create/mount encrypted files +echo "####################################################" +echo "Starting encfs." +echo "####################################################" +echo "$MYCMD4" +$MYCMD4 +echo + +# Check if link already exists +if [ ! -e $LINK ] +then + echo "####################################################" + echo "Creating symlink $LINK." + echo "####################################################" + echo "$MYCMD5" + $MYCMD5 + echo +fi + +read -n1 -r -p "Waiting for termination. Press any key ... " key +exit 0;