/bash-start-tor-at-boot

Automatically sets up ssh access over tor, that automatically starts after reboot, making your pc accessbile from anywhere (with tor).

Primary LanguageShellGNU Affero General Public License v3.0AGPL-3.0

Sets up tor over SSH

Ensures you can access your computer from anywhere in the world with a single command.

Install this bash dependency in other repo

  • In your other repo, include a file named: .gitmodules that includes:
[submodule "dependencies/bash-package-installer"]
 path = dependencies/bash-package-installer
 url = https://github.com/hiveminds/bash-package-installer
  • Create a file named install-dependencies.sh with content:
# Remove the submodules if they were still in the repo.
git rm --cached dependencies/bash-package-installer

# Remove and re-create the submodule directory.
rm -r "$SCRIPT_PATH/dependencies"/bash-package-installer
mkdir -p "$SCRIPT_PATH/dependencies"/bash-package-installer

# (Re) add the BATS submodules to this repository.
git submodule add --force https://github.com/hiveminds/bash-package-installer dependencies/bash-package-installer
  • Install the submodule with:
chmod +x install-dependencies.sh
./install-dependencies.sh

Call this bash dependency from other repo

After including this dependency you can use the functions in this module like:

#!/bin/bash

# Source the file containing the functions
source "$(dirname "${BASH_SOURCE[0]}")/src/main.sh"

# Execute prerequisites installation.
install_tor_and_ssh_requirements

# Configure tor such that it starts now, and when the pc reboots.
configure_tor_to_start_at_boot

The 0 and 1 after the package name indicate whether it will update the package manager afterwards (0 = no update, 1 = package manager update after installation/removal)

Testing

Put your unit test files (with extension .bats) in folder: /test/

Prerequisites

(Re)-install the required submodules with:

chmod +x install-bats-libs.sh
./install-bats-libs.sh

Install:

sudo gem install bats
sudo apt install bats -y
sudo gem install bashcov
sudo apt install shfmt -y
pre-commit install
pre-commit autoupdate

Pre-commit

Run pre-commit with:

pre-commit run --all

Tests

Run the tests with:

bats test

If you want to run particular tests, you could use the test.sh file:

chmod +x test.sh
./test.sh

Code coverage

bashcov bats test

How to help

  • Include bash code coverage in GitLab CI.
  • Add additional (relevant) pre-commit hooks.
  • Develop Bash documentation checks here, and add them to this pre-commit.