Skip to content

Commit

Permalink
fake-mac-address v1.1-rc3
Browse files Browse the repository at this point in the history
* dev:
  Checks if configuration parameters are set.
  Removes shebang from main body.
  Fixes unbound variables.
  Fixes fma::flow::linux::preflight_checks().
  • Loading branch information
Hologos committed Jun 22, 2022
2 parents cf43ba2 + 80c5e3c commit ffe1a58
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 0 additions & 2 deletions fake-mac-address
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ fi

# -- main program -------------------------------------------------------------

#! /usr/bin/env bash

fma::flow::preflight_checks

fma::flow::fake_mac_address
13 changes: 13 additions & 0 deletions libs/flow
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ function fma::flow::preflight_checks() {
echo
echo "Pre-flight checks"

echo "› checking configuration"
fma::flow::check_configuration

echo "› checking interface ${affected_interface}"
fma::network::interface_exists "${affected_interface}"

Expand All @@ -28,4 +31,14 @@ function fma::flow::fake_mac_address() {
fma::network::check_mac_address_after "${affected_interface}" "${fake_mac_address}"
}

function fma::flow::check_configuration() {
if [[ -z "${affected_interface+x}" ]]; then
fma::utils::terminate "Configuration parametr [affected_interface] is not set."
fi

if [[ -z "${fake_mac_address+x}" ]]; then
fma::utils::terminate "Configuration parametr [fake_mac_address] is not set."
fi

fma::utils::success "Configuration is set."
}
2 changes: 1 addition & 1 deletion libs/flow.linux
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function fma::flow::linux::preflight_checks() {
echo "› checking installed dependencies "

if ! fma::utils::is_installed "macchanger"; then
if fma::utils::is_installed "macchanger"; then
fma::utils::success "macchanger is installed"
else
fma::utils::fail "macchanger is not installed"
Expand Down
4 changes: 2 additions & 2 deletions libs/network
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ function fma::network::start_affected_interface() {

sudo ifconfig "${interface_to_start}" up

fma::utils::report_status "starting interface ${interface_to_restart}"
fma::utils::report_status "starting interface ${interface_to_start}"
}

function fma::network::stop_affected_interface() {
local interface_to_stop="${1}"

sudo ifconfig "${interface_to_stop}" down

fma::utils::report_status "stopping interface ${interface_to_restart}"
fma::utils::report_status "stopping interface ${interface_to_stop}"
}

function fma::network::restart_affected_interface() {
Expand Down

0 comments on commit ffe1a58

Please sign in to comment.