From c7b94d9aadde52d1dfaf9d7b4e2f57a92445ebba Mon Sep 17 00:00:00 2001 From: John Butler Date: Sat, 14 Dec 2019 05:08:32 +0100 Subject: [PATCH] Add setup files via upload --- LICENSE | 21 ++++++++++ README.md | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++ install.sh | 60 +++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 install.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8aa2645 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..55ac1da --- /dev/null +++ b/README.md @@ -0,0 +1,110 @@ +# ixguard-tools + +The tools and configuration files for custom ixguard scripts. + +To install: + +``` +$ sudo git clone https://github.com/johnjbutler/ixquick /ixquick +$ sudo bash /ixquick/install.sh +$ source ~/.bashrc +``` + +To update: +``` +$ sudo ixguard-update +``` + +or +``` +$ sudo su +$ ixguard-update +``` + +--- + +# Available Commands + +*It is recommended to go through each file to see how it works. The scripts are all commented and short!* + + +## pconfirm + +Confirms a user action + +``` +# Usage: + +$ pconfirm [-y | -Y ] [-n | -N ] [-q ] + + + +Flags +-------------- +-y Display default confirmation message when the user confirms +-Y Display custom when the user confirms +-n Display default rejection message when the user does not confirm +-N Display custom when the user does not confirm +-q Ask a user-defined confirmation question + + +Default Values +-------------- + "Operation confirmed" + "Operation cancelled" + "Are you sure?" +``` + + +## pgap + +Inserts a gap between standard out statements using echo + +``` +$ pgap [blank_lines_before] [text_to_output] [blank_lines_after] +``` + + +## pgit + +Installs a github repository based on shortcuts defined in `/ixguard/etc/pgit.conf` + +*Note: this is not currently used or maintained* + +``` +$ pgit +``` + + +## phelp + +Displays the relevant parts of the README + +``` +$ phelp +``` + + +## ixguard-update + +Updates ixguard-tools to the latest version + +*Note: `sudo` must be used if updating `/ixguard`* + +*Run `sudo su` followed by `ixguard-update` on certain systems (such as Raspberry Pi)* + +``` +# Default base directory is /ixguard + +$ ixguard-update [-d ] +``` + + +## ptype + +Outputs variable type as a string +Possible outputs: int, string + +``` +$ ptype $VAR +``` diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..1e8fb9a --- /dev/null +++ b/install.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Installs ixguard-tools the first time + +# set -x + +# Variables +RCPATH="$HOME/.bashrc" +PROFILEPATH="$HOME/.bash_profile" +RCSTR="[[ -f /ixquick/.bashrc ]] && source /ixquick/.bashrc # Loads ixguard .bashrc" +PROFILESTR="[[ -f ~/.bashrc ]] && source ~/.bashrc # Loads .bashrc" + +# Ensure bin files have execute permissions +# chmod -R +x /ixguard/bin + + +echo "-----------" +echo "Beginning installation..." +echo + +# Create the files if they don't exist +if [[ ! -f "$PROFILEPATH" ]]; then + echo "Creating $PROFILEPATH..." + touch "$PROFILEPATH" +fi + +if [[ ! -f "$RCPATH" ]]; then + echo "Creating $RCPATH..." + touch "$RCPATH" +fi + +echo + + +# Add contents of ixguard .bashrc to local .bashrc (so commands are available in non-login scripts too!) +# Only if the line isn't already there! +echo "Adding ixquick/bin to ~/.bashrc..." +if [[ -z $(grep -F "$RCSTR" "$RCPATH") ]]; then + # Error handling + echo "$RCSTR" >> "$RCPATH" && echo "Added!" || echo "ERROR: Failed to add line to .bashrc! Try adding manually" +else + echo "Already added! Skipping..." +fi + +echo + +echo "Adding ~/.bashrc to ~/.bash_profile..." +# Make sure .bash_profile pulls from .bashrc for cross-compatibility +# Only if it hasn't been sourced already! +if [[ -z $(grep -F "~/.bashrc" "$PROFILEPATH") ]]; then + # Error handling + echo "$PROFILESTR" >> "$PROFILEPATH" && echo "Added!" || echo "ERROR: Failed to add line to .bash_profile! Try adding manually" +else + echo "Already added! Skipping..." +fi + +echo +echo "-----------" +echo "Installation Complete!" +echo "-----------"