Monday, 14 March 2011

Linux : Change runlevel

Use telinit :-
su -c 'telinit 3'

Thursday, 10 March 2011

Oracle : oraenv gives XPointer evaluation failed

In 11G+ this is due ORACLE_BASE not being set in the course of running oraenv

What is happening is $ORACLE_HOME/bin/orabase is being run to update $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml and erroring as the particular key it is looking for is not in the file ( PROPERTY NAME="ORACLE_BASE" I guess) - however the error is ignored resulting in $ORACLE_BASE being unset

Made a one line change to oraenv to check the return value and use the OLD_ORACLE_BASE - which will probably work most of the time ;)
ORACLE_BASE=`$ORABASE_EXEC`
[ "$?" -ne 0 ] && { echo "Warning - failure of $ORABASE_EXEC"; ORACLE_BASE=$OLD_ORACLE_BASE; }  # New line


Thursday, 16 December 2010

Confluence : FIx space permissions via SQL

--General query
select s.spacename,sp.*,s.*
from SPACEPERMISSIONS sp,
spaces s
where 1=1
and s.spaceid = sp.spaceid
order by 1,2

--Look up the exact space name
select * from spaces

--Check what permid range is available
select * from SPACEPERMISSIONS
where spaceid in (select spaceid from spaces where spacename = 'IT')
order by 1

commit

-- Add full permissions to the confluence-administrators group for a single space
-- * Set the offest to a range which allows 14 rows to be added
-- * Use either perm_groupname OR perm_username but not both
-- * Replace anotheruser as appropriate
insert into SPACEPERMISSIONS
with target as (
select
3620 offset,
'confluence-administrators' perm_groupname,
NULL perm_username,
'IT' spacename,
'anotheruser' audit_username
from dual),
ptypes as (
SELECT 'COMMENT' permtype from dual union all
SELECT 'CREATEATTACHMENT' from dual union all
SELECT 'EDITBLOG' from dual union all
SELECT 'EDITSPACE' from dual union all
SELECT 'EXPORTPAGE' from dual union all
SELECT 'EXPORTSPACE' from dual union all
SELECT 'REMOVEATTACHMENT' from dual union all
SELECT 'REMOVEBLOG' from dual union all
SELECT 'REMOVECOMMENT' from dual union all
SELECT 'REMOVEMAIL' from dual union all
SELECT 'REMOVEPAGE' from dual union all
SELECT 'SETPAGEPERMISSIONS' from dual union all
SELECT 'SETSPACEPERMISSIONS' from dual union all
SELECT 'VIEWSPACE' from dual)
select
t.offset+rownum permid,
s.spaceid,
p.permtype,
t.groupname permgroupname,
t.perm_username permusername,
t.audit_username creator,
sysdate creationdate,
t.audit_username lastmodifier,
sysdate lastmoddate
from target t,
ptypes p,
spaces s
where t.spacename = s.spacename (+)

Friday, 19 November 2010

Keeping an SSH tunnel (passworded) running perniciously

* Download and compile sshpass and place in DIR
http://sshpass.sourceforge.net/

* Create a script like this
DIR=/?
LOG=$DIR/ssh.log
LOCAL_PORT=15000
REMOTE_SERVER=192.168.69.69

REMOTE_PORT=1521
echo "`date` - Restarting " >> $LOG

export SSHPASS='PASSWORD'
$DIR/sshpass -e ssh  $USERNAME@ $REMOTE_SERVER -L${LOCAL_PORT}:localhost:${REMOTE_PORT} -N -o ServerAliveInterval=30 -o TCPKeepAlive=yes -o ServerAliveCountMax=172800
echo "`date` - Ending " >> $LOG

* Add the following to /etc/inittab - replace xxxx with a unique id, USER with the user to login as and and script.sh accordingly with full path
xxxx:35:respawn:/bin/su - USER "/?/script.sh"

* Get the init process to reload (as root)
kill -HUP 1

* Test

Thursday, 18 November 2010

Keeping Your SSH Sessions Alive Through Firewalls

To send a keep alive every 4 minutes either change ~/.ssh/config or /etc/ssh/ssh_config to add
Host *   
     ServerAliveInterval 240


Wednesday, 13 October 2010

Windows : More RDP-related commands

Connect to a share to get an admin connections
* net use /user:targetdomain\administrator \\targetmachine

List Current Users on a machine
* quser /server:targetmachine (shows session id - better as also shows login and idle time)
* qwinsta /server:serverName
Log a user off a machine

* logoff sessionId /server:targetmachine<br />

Tuesday, 5 October 2010

Sharepoint - Where is the data hidden


SELECT TOP 1000 [tp_ID]
      ,tp_author
      ,tp_version
      ,[datetime1]+8 x1
      ,[datetime2]+7 x2
      ,[datetime1]
      ,[datetime2]
      ,[nvarchar1]
      ,[nvarchar2]
      ,[nvarchar3]
      ,[nvarchar4]
      ,[nvarchar5]
      ,[nvarchar6]
      ,[nvarchar7]
      ,[datetime3]
      ,[datetime4]
      ,[datetime5]
      ,[int1]
      ,[int2]
      ,[int3]
      ,[int4]
      ,[int5]
      ,[int6]
  FROM [WSS_Content].[dbo].[AllUserData]
  where 1=1
  --and tp_ListId = 'DA7307B0-4D77-4DEE-A347-D183BE27CCC3'
  and tp_DirName = 'hr/holidays/Lists/Absences'
  and nvarchar5 = 'IT Development'
  and tp_author = 51
  and tp_ID = 709
  order by datetime1 desc