Skip to content

Commit

Permalink
Add setup files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
John Butler authored Dec 14, 2019
0 parents commit c7b94d9
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
110 changes: 110 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <Confirmation message>] [-n | -N <Rejection message>] [-q <Question>]
Flags
--------------
-y Display default confirmation message when the user confirms
-Y Display custom <Confirmation message> when the user confirms
-n Display default rejection message when the user does not confirm
-N Display custom <Rejection message> when the user does not confirm
-q Ask a user-defined confirmation question
Default Values
--------------
<Confirmation message> "Operation confirmed"
<Rejection message> "Operation cancelled"
<Question> "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 <github-shortcut>
```


## phelp

Displays the relevant parts of the README

```
$ phelp <command>
```


## 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 <Base directory>]
```


## ptype

Outputs variable type as a string
Possible outputs: int, string

```
$ ptype $VAR
```
60 changes: 60 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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 "-----------"

0 comments on commit c7b94d9

Please sign in to comment.