Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to Use Functions and Conditional Execution #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions UbuntuServer_18.04LTS/helpers.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash

spinner ()
{
# Current user ID
CUID="$(id -u)"

spinner () {
bar=" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
barlength=${#bar}
i=0
echo ""
while ((i < 100)); do
n=$((i*barlength / 100))
printf "\e[00;34m\r[%-${barlength}s]\e[00m" "${bar:0:n}"
Expand All @@ -14,38 +17,39 @@ spinner ()
}


# Print formatted message to stdout and stderr
perr() {
printf "[%s]: %s\n" "${MYNAME}" "${@}" >&2
}

# Show "Done."
function say_done() {
echo " "
echo -e "Done."
say_done() {
printf "%s\n" "Done."
say_continue
}


# Ask to Continue
function say_continue() {
echo -n " To EXIT Press x Key, Press ENTER to Continue"
read acc
say_continue() {
printf "%s" "To EXIT Press x Key, Press ENTER to Continue: "
read -r acc
if [ "$acc" == "x" ]; then
exit
exit 0
fi
echo " "
}


# Obtain Server IP
function __get_ip() {
# Obtain Server IP, store for later use
__get_ip() {
# This will be accessible to the script after sourcing,
# so the variable can be re-used instead of this function
serverip=$(ip route get 1 | awk '{print $7;exit}')
echo $serverip
}


# Copy Local Config Files
function tunning() {
whoapp=$1
cp templates/$whoapp /root/.$whoapp
cp templates/$whoapp /home/$username/.$whoapp
chown $username:$username /home/$username/.$whoapp
tuning() {
cp templates/"${1}" /root/."${1}"
cp templates/"${1}" /home/"${username}"/."${1}"
chown "${username}":"${username}" /home/"${username}"/."${1}"
}

Loading