вторник, 20 мая 2014 г.

permit deploy nagios conf using nconf

/etc/sudoers
apache  ALL =(ALL) NOPASSWD:/sbin/service
#Default requiretty

/var/www/html/nconf/config/deployment.ini
;; LOCAL deployment ;;

[extract config]
type        = local
source_file = "/var/www/html/nconf/output/NagiosConfig.tgz"
target_file = "/tmp/"
action      = extract

[copy collector config]
type        = local
source_file = "/tmp/Default_collector/"
target_file = "/etc/nagios/conf.d/Default_collector/"
action      = copy

[copy global config]
type        = local
source_file = "/tmp/global/"
target_file = "/etc/nagios/conf.d/global/"
action      = copy
reload_command = "sudo /sbin/service nagios reload"

понедельник, 12 мая 2014 г.

create linux user with password in one line

#!/bin/bash
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
    if [ "$#" -eq 2 ]; then
        egrep "^$username" /etc/passwd >/dev/null
        if [ $? -eq 0 ]; then
            echo "$username exists!"
            exit 1
        else
            pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
            useradd -m -p $pass $username
            [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
        fi
    else
    echo "Need two parameters"
    exit 3
    fi
else
    echo "Only root may add a user to the system"
    exit 2
fi

Create oracle full access user

create role OIM_Admin;
-- usualy it is bad practices grant dba role
grant dba to OIM_ADMIN;

-- alternative way 
grant all privileges to OIM_ADMIN;
-- or 
set pagesize 0
spool grant_rw.sql
select 'grant all privileges on '||owner||'.'||table_name||' to OIM_ADMIN;' from all_tables;
select 'grant select on '||owner||'.'||view_name||' to OIM_ADMIN;' from all_views;
spool off
@grant_rw.sql


CREATE USER admin_user  PROFILE "DEFAULT"
    IDENTIFIED BY "somepassword" DEFAULT TABLESPACE "USERS"
    TEMPORARY TABLESPACE "TEMP"
    ACCOUNT UNLOCK;

GRANT CREATE SESSION, ALTER SESSION TO admin_user;

grant OIM_ADMIN to admin_user;

Create oracle readonly user for all schemas (including system)

sqlplus "/as sysdba"

create role OIM_REPORTER;

-- Assigning Privileges to role
set pagesize 0
spool grant_ro.sql
select 'grant select on '||owner||'.'||table_name||' to OIM_REPORTER;' from all_tables;
select 'grant select on '||owner||'.'||view_name||' to OIM_REPORTER;' from all_views;
spool off
-- Execute it
@grant_ro.sql

CREATE USER ro_user  PROFILE "DEFAULT"
    IDENTIFIED BY "somepassword" DEFAULT TABLESPACE "USERS"
    TEMPORARY TABLESPACE "TEMP"
    ACCOUNT UNLOCK;
-- Permit the user connect to database
GRANT CREATE SESSION, ALTER SESSION TO ro_user;
-- Assigning role to user
GRANT OIM_REPORTER TO ro_user;

Note:
If you create some new tables you have to grant the permission to role.