Start simplifying user
This commit is contained in:
42
installJRMC
42
installJRMC
@@ -22,7 +22,6 @@ shopt -s extglob
|
|||||||
SCRIPTVERSION="1.0b6"
|
SCRIPTVERSION="1.0b6"
|
||||||
OUTPUTDIR="$PWD/output"
|
OUTPUTDIR="$PWD/output"
|
||||||
CREATEREPO_WEBROOT="/var/www/jriver"
|
CREATEREPO_WEBROOT="/var/www/jriver"
|
||||||
EXEC_USER=$(whoami)
|
|
||||||
SERVICEDIR="/usr/lib/systemd/system"
|
SERVICEDIR="/usr/lib/systemd/system"
|
||||||
|
|
||||||
# MC version
|
# MC version
|
||||||
@@ -57,14 +56,16 @@ printHelp() {
|
|||||||
See SERVICES section below for a list of possible services to install
|
See SERVICES section below for a list of possible services to install
|
||||||
--service-user USER
|
--service-user USER
|
||||||
Install systemd services and containers for user USER (Default: current user)
|
Install systemd services and containers for user USER (Default: current user)
|
||||||
|
--service-type user|system
|
||||||
|
Installs service(s) as a system or user service (Default: per-service)
|
||||||
--container, -c CONTAINER (TODO: Under construction)
|
--container, -c CONTAINER (TODO: Under construction)
|
||||||
See CONTAINERS section below for a list of possible services to install
|
See CONTAINERS section below for a list of possible services to install
|
||||||
--createrepo
|
--createrepo
|
||||||
Build rpm, copy to webroot, and run createrepo. Use in conjunction with --build=TARGET for crossbuilding repos
|
Build rpm, copy to webroot, and run createrepo. Use in conjunction with --build=TARGET for crossbuilding repos
|
||||||
--createrepo-webroot PATH
|
--createrepo-webroot PATH
|
||||||
The webroot directory to install the repo (Default: /var/www/jriver)
|
Specify the webroot directory to install the repo (Default: /var/www/jriver)
|
||||||
--createrepo-user USER
|
--createrepo-user USER
|
||||||
The web server user (Default: current user)
|
Specify the web server user
|
||||||
--compat
|
--compat
|
||||||
Build/install RPM without minimum library specifiers
|
Build/install RPM without minimum library specifiers
|
||||||
--version, -v
|
--version, -v
|
||||||
@@ -74,7 +75,7 @@ printHelp() {
|
|||||||
--help, -h
|
--help, -h
|
||||||
Print help dialog and exit
|
Print help dialog and exit
|
||||||
--uninstall, -u
|
--uninstall, -u
|
||||||
Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files)
|
Uninstall JRiver MC, remove services, and remove firewall rules (does not remove library files)
|
||||||
|
|
||||||
SERVICES
|
SERVICES
|
||||||
jriver-mediaserver
|
jriver-mediaserver
|
||||||
@@ -94,7 +95,7 @@ printHelp() {
|
|||||||
Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
|
Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
|
||||||
current display incremented by 1 (Xvnc))
|
current display incremented by 1 (Xvnc))
|
||||||
jriver-createrepo
|
jriver-createrepo
|
||||||
Install hourly service to build latest MC RPM and run createrepo
|
Install hourly service to build latest MC RPM and run createrepo ()
|
||||||
|
|
||||||
CONTAINERS (TODO: Under construction)
|
CONTAINERS (TODO: Under construction)
|
||||||
mediacenter-xvnc
|
mediacenter-xvnc
|
||||||
@@ -107,10 +108,14 @@ init() {
|
|||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare version_source
|
declare version_source
|
||||||
declare -g SERVICE_USER CREATEREPO_USER MCVERSION MVERSION MCPKG
|
declare -g USER SERVICE_USER CREATEREPO_USER MCVERSION MVERSION MCPKG
|
||||||
|
|
||||||
getOS
|
getOS
|
||||||
|
|
||||||
|
USER="${USER:-$(id -un)}"
|
||||||
|
SERVICE_USER="${SERVICE_USER:-$USER}"
|
||||||
|
CREATEREPO_USER="${CREATEREPO_USER:-$USER}"
|
||||||
|
|
||||||
# Make sure universe repo is installed on Ubuntu
|
# Make sure universe repo is installed on Ubuntu
|
||||||
if [[ "$ID" == "ubuntu" ]]; then
|
if [[ "$ID" == "ubuntu" ]]; then
|
||||||
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
|
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
|
||||||
@@ -152,9 +157,6 @@ init() {
|
|||||||
|
|
||||||
parseInput "$@"
|
parseInput "$@"
|
||||||
|
|
||||||
SERVICE_USER="${SERVICE_USER:-$EXEC_USER}"
|
|
||||||
CREATEREPO_USER="${CREATEREPO_USER:-$EXEC_USER}"
|
|
||||||
|
|
||||||
# Select MC version to work with
|
# Select MC version to work with
|
||||||
if [[ -v MCVERSION ]]; then
|
if [[ -v MCVERSION ]]; then
|
||||||
version_source="user input"
|
version_source="user input"
|
||||||
@@ -205,20 +207,22 @@ getOS() {
|
|||||||
|
|
||||||
|
|
||||||
ifSudo() {
|
ifSudo() {
|
||||||
declare _user="root"
|
declare user="root"
|
||||||
if [[ $# == 0 ]]; then
|
if [[ $# == 0 ]]; then
|
||||||
[[ "$EXEC_USER" == "root" ]]; return $?
|
[[ "$USER" == "root" ]]
|
||||||
|
return $?
|
||||||
elif [[ $# -eq 2 && "$1" == "-u" ]]; then
|
elif [[ $# -eq 2 && "$1" == "-u" ]]; then
|
||||||
_user="$2"
|
user="$2"
|
||||||
[[ "$EXEC_USER" == "$_user" ]]; return $?
|
[[ "$USER" == "$user" ]]
|
||||||
|
return $?
|
||||||
elif [[ $# -gt 2 && "$1" == "-u" ]]; then
|
elif [[ $# -gt 2 && "$1" == "-u" ]]; then
|
||||||
_user="$2"
|
user="$2"
|
||||||
shift 2
|
shift 2
|
||||||
fi
|
fi
|
||||||
if [[ "$_user" == "$EXEC_USER" ]]; then
|
if [[ "$user" == "$USER" ]]; then
|
||||||
"$@"
|
"$@"
|
||||||
else
|
else
|
||||||
sudo -u "$_user" "$@"
|
sudo -u "$user" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,7 +502,7 @@ addRepo() {
|
|||||||
gpgcheck=0
|
gpgcheck=0
|
||||||
EOF'
|
EOF'
|
||||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
|
||||||
# MVERSION depends on $BASE unless --MCVERSION is passed
|
# MVERSION depends on $BASE unless --mcversion is passed
|
||||||
installPackage wget
|
installPackage wget
|
||||||
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | ifSudo apt-key add - &>/dev/null
|
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | ifSudo apt-key add - &>/dev/null
|
||||||
ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" &>/dev/null
|
ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" &>/dev/null
|
||||||
@@ -768,6 +772,10 @@ runCreaterepo() {
|
|||||||
|
|
||||||
installPackage createrepo_c
|
installPackage createrepo_c
|
||||||
|
|
||||||
|
# if [[ "$CREATEREPO_USER" != "$USER" ]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If the webroot does not exist, create it
|
# If the webroot does not exist, create it
|
||||||
if [[ ! -d "$CREATEREPO_WEBROOT" ]]; then
|
if [[ ! -d "$CREATEREPO_WEBROOT" ]]; then
|
||||||
#cr_mkdir_cmd="sudo -u $CREATEREPO_USER mkdir -p $CREATEREPO_WEBROOT"
|
#cr_mkdir_cmd="sudo -u $CREATEREPO_USER mkdir -p $CREATEREPO_WEBROOT"
|
||||||
|
|||||||
Reference in New Issue
Block a user