Skip to content

Commit

Permalink
Release of version v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stablestud committed Feb 27, 2019
2 parents 2e72037 + 5f4ec9f commit 38ca920
Show file tree
Hide file tree
Showing 31 changed files with 1,066 additions and 722 deletions.
228 changes: 160 additions & 68 deletions README.md

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
## Things considered for a future release/next release, ordered by priority

## Must:
* README.md update

## Should:
* interactive ability to set the update frequency
* save statistics to var/ and read from Adsorber

## Could:
* OpenRC support
* log-file
* save statistics to var/ and read from Adsorber
* bash completion
* proper unittest

Expand Down
8 changes: 7 additions & 1 deletion misc/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
This directory contains a few tools which may aid in the development of Adsorber.
### This directory contains a few tools which may aid in the development of Adsorber.

#### clean.sh
Clean the script's root directory from junk (e.g whitelist, blacklist).

#### shellcheck.sh
Checks all script files with the shellcheck application against common script issues.
3 changes: 3 additions & 0 deletions misc/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# Cleans the scripts root directory of config files created by portable_adsorber.sh

readonly source_dir_path="$(cd "$(dirname "${0}")"/.. && pwd)"

Expand All @@ -23,3 +24,5 @@ if [ -f "${source_dir_path}/sources.list" ]; then
rm "${source_dir_path}/sources.list" -f
echo "Removed sources.list"
fi

echo "Done."
9 changes: 5 additions & 4 deletions misc/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ readonly script_dir_path="$(cd "$(dirname "${0}")" && pwd)"

if ! command -v shellcheck 2>/dev/null 1>&2; then
echo "Shellcheck must be installed."
exit 1
fi

echo "Running shellcheck ..."

(
cd -P -e "${script_dir_path}" || { echo "Couldn't descend to ${script_dir_path}"; exit 1; }
cd -P "${script_dir_path}" || { echo "Couldn't descend to ${script_dir_path}"; exit 1; }

shellcheck -x \
"${script_dir_path}/shellcheck.sh" \
"${script_dir_path}/../src/bin/adsorber" \
"${script_dir_path}/../portable_adsorber.sh" \
"${script_dir_path}/../install_to_system.sh" \
"${script_dir_path}/../remove_from_system.sh" \
"${script_dir_path}/shellcheck.sh"
"${script_dir_path}/../place_files_onto_system.sh" \
"${script_dir_path}/../remove_files_from_system.sh"

echo "Done."
)
75 changes: 19 additions & 56 deletions install_to_system.sh → place_files_onto_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ printHelp()
echo " Will place Adsorbers executables and other"
echo " files relevant to Adsorber into the system."
echo
printf "\\033[4;37mNote\\033[0m: Adsorbers own 'install' command will not do the same action as\\n"
printf "\\033[4;37mNote\\033[0m: Adsorbers own 'setup' command will not do the same action as\\n"
echo "this script, as it will only setup the scheduler and backup the original hosts file."
echo "You may want to run 'adsorber install' afterwards"
echo "You may want to run 'adsorber setup' afterwards"
echo
echo "Usage: ${0} [option]:"
echo
echo "Options:"
echo " -y, --yes automatically reply the prompt with yes"
echo " -y, --yes automatically reply the confirmation prompt with yes"
echo " -h, --help show this help screen"
echo
printLocation
Expand All @@ -65,35 +65,31 @@ if [ "${prompt}" = "help" ] || [ "${prompt}" = "h" ] || [ "${prompt}" = "-h" ] |
printHelp
fi

echo "Current script location: ${script_dir_path}"
printLocation
echo
printf "Adsorber will be placed into /usr/local/*, which is the default path for external scripts.\\n\\n"

if [ -z "${prompt}" ]; then
printf "Are you sure you want to install Adsorber into the system? [(Y)es/(N)o]: "
printf "Are you sure you want to place Adsorbers files onto the system? [(y)es/(N)o]: "
read -r prompt
fi

case "${prompt}" in
-[Yy] | --[Yy][Ee][Ss] | [Yy] | [Yy][Ee][Ss] )
:
;;
echo
;;
* )
echo "Installation to the system has been cancelled."
echo "Placing files onto the system has been cancelled."
exit 1
;;
esac

# Check if user is root, if not exit.
if [ "$(id -g)" -ne 0 ]; then
echo "You need to be root to install Adsorber into the system." 1>&2
echo "You need to be root to place Adsorbers files onto the system." 1>&2
exit 126
fi

echo

##[ Main exectuable ]###########################################################
echo "Placing main executable to ${executable_path}"
echo "Placing main executable (src/bin/adsorber) to ${executable_path}"

mkdir -p "$(dirname ${executable_path})"

Expand All @@ -103,50 +99,27 @@ sed "s|^readonly library_dir_path=\"\${executable_dir_path}/\\.\\./lib/\"$|reado
| sed "s|^readonly config_dir_path=\"\${executable_dir_path}/\\.\\./\\.\\./\"$|readonly config_dir_path=\"${config_dir_path}\"|g" \
> "${executable_path}"

chmod u=rwx,g=rx,o=rx "${executable_path}" \
|| {
printf "Couldn't set permissions for %s" "${executable_path}"
}
chown root:root "${executable_path}" \
|| {
printf "Couldn't set ownership of %s" "${executable_path}"
}
chmod a+x "${executable_path}"


##[ Libraries ]#################################################################
echo "Placing other executables to ${library_dir_path}"
echo "Placing other executables (src/lib/) to ${library_dir_path}"

mkdir -p "${library_dir_path}"

cp -r "${script_dir_path}/src/lib/." "${library_dir_path}"

chmod -R u=rwx,g=rx,o=rx "${library_dir_path}" \
|| {
printf "Couldn't set permissions for %s" "${library_dir_path}"
}
chown -R root:root "${library_dir_path}" \
|| {
printf "Couldn't set ownership of %s" "${library_dir_path}"
}

##[ Shareables ]################################################################
echo "Placing miscellaneous to ${shareable_dir_path}"
echo "Placing miscellaneous (src/share/) to ${shareable_dir_path}"

mkdir -p "${shareable_dir_path}"

cp -r "${script_dir_path}/src/share/." "${shareable_dir_path}"

chmod -R u=rwx,g=rx,o=rx "${shareable_dir_path}" \
|| {
printf "Couldn't set permissions for %s" "${shareable_dir_path}"
}
chown -R root:root "${shareable_dir_path}" \
|| {
printf "Couldn't set ownership of %s" "${shareable_dir_path}"
}

##[ Config files ]##############################################################
echo "Placing config files to ${config_dir_path}"
echo "Copying config files (src/share/default/) to ${config_dir_path}"

mkdir -p "${config_dir_path}"

Expand All @@ -155,27 +128,17 @@ cp "${script_dir_path}/src/share/default/default-blacklist" "${config_dir_path}/
cp "${script_dir_path}/src/share/default/default-whitelist" "${config_dir_path}/whitelist"
cp "${script_dir_path}/src/share/default/default-sources.list" "${config_dir_path}/sources.list"

chmod -R u=rwx,g=rx,o=rx "${config_dir_path}" \
|| {
printf "Couldn't set permissions for %s" "${config_dir_path}"
}
chown -R root:root "${config_dir_path}" \
|| {
printf "Couldn't set ownership of %s" "${config_dir_path}"
}

echo
echo "Adsorber files have been successfully placed onto the system."
printf "\\033[1;37mTo start going (to setup the scheduler and to backup the hosts file) run 'adsorber setup'\\033[0m\\n"

## We don't run Adsorber after installation yet
#adsorber install \
#adsorber setup --noformatting \
# || {
# printf "\033[0;93mAdsorber was installed on your system, however something went wrong at\\n"
# printf "\\n\033[0;93mAdsorber has been placed onto your system, however something went wrong at\\n"
# printf "running it.\\n"
# printf "If a proxy server is in use, please change the config file\\n"
# printf "(${config_dir_path}/adsorber.conf) to the appropriate proxy server.\\n\033[0m"
# echo "Run 'adsorber install' to try again."
# echo "Run 'adsorber setup' to try again."
# }

echo "Installation completed."
printf "\\033[1;37mTo start going and to setup the scheduler or to backup the hosts file run 'adsorber install'\\033[0m\\n"
echo "You can now delete this folder."
7 changes: 5 additions & 2 deletions portable_adsorber.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runAdsorber()
{
echo ""
# shellcheck disable=SC2086
( "${source_dir_path}/src/bin/adsorber" ${parameters} )
( "${source_dir_path}/src/bin/adsorber" "${parameters}" "--no-scheduler" )
exit_code="${?}"
echo ""
return "${exit_code}"
Expand All @@ -25,10 +25,13 @@ runAdsorber()
if runAdsorber; then
echo "Adsorber in portable-mode exited with code ${exit_code}."
else
# I defined exit code 80 as an error code if wrong or no input has been made
# I defined exit code 80 as an error code in the adsorber main executable
# if wrong or no input has been made
if [ "${exit_code}" -eq 80 ]; then
echo "You've supplied no or wrong parameters."
fi

echo "Adsorber in portable-mode exited with code ${exit_code}. Thats an error."

exit ${exit_code}
fi

0 comments on commit 38ca920

Please sign in to comment.