gravity-sync/includes/gs-root.sh
Michael Stanclift d97f92ccea
3.3.3 is 3.4.0 (#185)
* new first line of script

* no requested

* Abort!

* Test silent folder validation

* sameline

* echo newline

* echo_sameline

* what happened?

* sameline for ssh

* sqlite sameline

* Lower case

* Reset line

* clear line

* Flip the line

* version update

* Backup lowercase

* More lowercase

* Remove file names from standard messages

* Breakout backup message

* Output backup folder size

* Just H

* Invalid replication settings

* Compare updated

* Colors and updates

* Lower case for version output

* For Pihole

* Cron cleanup

* Sudo, or no sudo.

* Branch!

* Silent error validate

* Silent error validate

* Clearing up status messages

* Records

* Primary and secondary

* Gravity database

* Domain Database

* Backup output cleanup

* Move file permission validation into new functions

* Change restart

* UI variables test

* Breakout UI variables into new file

* Unified validation functions

* Replace text strings with variables

* Replace text strings with variables

* Replace logging with variables

* Convert backup to UI variables

* Switch restore to UI variables

* Fix bug where gravity database did not restore

* App validation checks

* Rev to 3.4.0

* Convert Push functions to new strings

* Completing push UI changes

* remove added line

* Move purge to UI strings

* Move automation to UI strings

* Move core strings into UI

* Exit strings

* First pass at hashing UI

* Escape the remote system query (#179)

* hashing committed

Co-authored-by: Michael Stanclift <vmstan@mstanclift-a03.local>
Co-authored-by: Veduco <59983694+Veduco@users.noreply.github.com>
2021-04-01 15:16:20 -05:00

71 lines
1.7 KiB
Bash

# GRAVITY SYNC BY VMSTAN #####################
# gs-root.sh #################################
# For documentation or downloading updates visit https://github.com/vmstan/gravity-sync
# This code is called from the main gravity-sync.sh file and should not execute directly!
## Sudo Creation Task
function task_sudo {
TASKTYPE='SUDO'
MESSAGE="${MESSAGE}: ${TASKTYPE}"
echo_good
MESSAGE="Creating sudoers.d template file"
echo_stat
NEW_SUDO_USER=$(whoami)
echo -e "${NEW_SUDO_USER} ALL=(ALL) NOPASSWD: ALL" > ${LOCAL_FOLDR}/templates/gs-nopasswd.sudo
error_validate
MESSAGE="Installing sudoers.d file on $HOSTNAME"
echo_stat
sudo install -m 0440 ${LOCAL_FOLDR}/templates/gs-nopasswd.sudo /etc/sudoers.d/gs-nopasswd
error_validate
exit_withchange
}
## Root Check
function root_check {
if [ ! "$EUID" -ne 0 ]
then
TASKTYPE='ROOT'
MESSAGE="${MESSAGE} ${TASKTYPE}"
echo_fail
MESSAGE="${PROGRAM} should not run as 'root'"
echo_warn
exit_nochange
fi
}
function new_root_check {
CURRENTUSER=$(whoami)
if [ ! "$EUID" -ne 0 ]
then
LOCALADMIN=""
else
# Check Sudo
SUDOCHECK=$(groups ${CURRENTUSER} | grep -e 'sudo' -e 'wheel')
if [ "$SUDOCHECK" == "" ]
then
LOCALADMIN="nosudo"
else
LOCALADMIN="sudo"
fi
fi
if [ "$LOCALADMIN" == "nosudo" ]
then
TASKTYPE='ROOT'
MESSAGE="${MESSAGE} ${TASKTYPE}"
echo_fail
MESSAGE="${CURRENTUSER} has insufficent user rights for ${PROGRAM}"
echo_warn
exit_nochange
fi
}