ACC SHELL

Path : /usr/bin/
File Upload :
Current File : //usr/bin/pm-profiler

#!/bin/bash
#
# pm-profiler command line tool
#
# Copyright (C) 2008,2009 Holger Macht <hmacht@suse.de>
#
# This file is released under the GPLv2.
#

function list_profiles {
    for I in /etc/pm-profiler/*; do
	[ -d $I ] && echo `basename $I`
    done
}

function show_profile_description {
    . /etc/pm-profiler/$1/config
    echo $NAME:
    echo $DESCRIPTION
}

function set_active_profile {
    if [ "$UID" != "0" ]; then
	echo "You must be root to enable a profile"
	exit 1
    fi
    /usr/lib/pm-profiler/enable-profile $1
}

function get_active_profile {
    cat /var/run/pm-profiler.profile
}

function list_current_settings {
    echo "PROFILE=`get_active_profile`"
    /usr/lib/pm-profiler/get-current-settings
}

function usage {
    echo
    echo "Usage: pm-profiler [OPTIONS]"
    echo
    echo " Profiles:"
    echo -e "\t -x, --list-profiles\t\t show all available profiles"
    echo -e "\t -X, --show-profile-description\t show profile description"
    echo -e "\t -g, --get-active-profile\t get the currently active profile"
    echo -e "\t -l, --list-current-settings\t get the currently active settings"
    echo -e "\t -e <x>, --set-active-profile <x> switch currently active profile"
    echo
}


TEMP=`getopt -o e:hxX:gl --long set-active-profile:,\
help,list-profiles,show-profile-description:,get-active-profile,list-current-settings -- "$@"`

if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
   
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

while true ; do
    case "$1" in
	-x|--list-profiles) list_profiles ; shift ;;
	-X|--show-profile-description) show_profile_description $2 ; shift 2 ;;
        -e|--set-active-profile) set_active_profile $2 ; shift 2 ;;
        -g|--get-active-profile) get_active_profile ; shift ;;
        -l|--list-current-settings) list_current_settings ; shift ;;
	-h|--help) usage ; shift ;;
        --) shift ; break ;;
        *) echo "Internal error!" ; exit 1 ;;
    esac
done

ACC SHELL 2018