• Author Owner

    bug on this script it should be

    #!/bin/sh -e
    # Generate 66 frontend service for dbus services
    # usage: pass the absolute paths of dbus service definitions
    # specifying the user privilegies:
    #	% sudo ./66-generator /usr/share/dbus-1/system-services/* (for the system bus)
    # 	% sudo ./s6-generator -u /usr/share/dbus-1/services/* (for the session bus)
    
    # Path definition need to correspond to the
    # flag used at compilation time. The default is
    # is used in this script.
    
    # Safe place for sysadmin service.
    # Packager should install service at
    # /usr/share/66/service. So, no conflicts.
    ServiceRoot="/etc/66/service"
    
    # The -u option specify the user privilegies to handles
    # Packager should install service for user
    # at /usr/share/66/service/user and user have
    # this own directory at ${HOME}/.66/service. So, no conflicts.
    ServiceUser="/etc/66/service/user/"
    
    # Handles root or user? root is default
    root=1
    
    # User or root
    if [ ${1:0:1} == "-" ]; then
    	Services=$ServiceUser
    	shift
    else
    	Services=$ServiceRoot
    	root=0
    fi
    
    for service in "$@"; do
    	# Get the name from the command line
    	name_=$(awk -F= '$1 == "Name" {print $2}' "$service")
    	exec_=$(awk -F= '$1 == "Exec" {print $2}' "$service")
    	# Get the user account for the executable execution
    	runas_=$(awk -F= '$1 == "User" {print $2}' "$service")
    
    	# This constantly overwrite an existing frontend file
    	# Append the frontend file name with -dbus to be specific
    	echo "[main]
    @type = classic
    @description = \"$name_ dbus service\"
    @version = 0.0.1
    @intree = dbus" > $Services/$name_-dbus
    
    	# Give a correct permissions. Root can not handles
    	# user services and user cannot control root services.
    	# The term user is a generic one understood by 66 and
    	# replaced at parse time by the correct account name
    	# of the owner of the process
    	if ((!root)); then
    		echo "@user = ( root )" >> $Services/$name_-dbus
    	else
    		echo "@user = ( user )" >> $Services/$name_-dbus
    	fi
    
    	# Command to execute
    	echo "
    [start]
    @execute = ($exec_)" >> $Services/$name_-dbus
    
    	# Respect the account name to launch the script
    	if [ -n $runas_ ]; then
    		# only root can handles user privilegies.
    		# owner of the process is the default with 66.
    		if ((!root)) && [ "$runas_" != "root" ]; then
    			echo "@runas = $runas_" >> $Services/$name_-dbus
    		fi
    	fi
    done

    replacing /tmp/66/service/ by $Services

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment