LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File x2goserver-sqlite3.patch of Package x2goserver (Project X11:RemoteDesktop:x2go)

diff --git a/x2gopgwrapper_sqlite b/x2gopgwrapper_sqlite
index 31edb49..20325a1 100755
--- a/x2gopgwrapper_sqlite
+++ b/x2gopgwrapper_sqlite
@@ -9,15 +9,15 @@ DATABASE=/var/db/x2go/x2go_sessions
 case "$1" in
 
 getdisplays)
-  echo "select '|'||display||'|' from sessions;"|sqlite $DATABASE
+  echo "select '|'||display||'|' from sessions;"|sqlite3 $DATABASE
   ;;
 
 getports)
-  echo "select '|'||port||'|' from used_ports;"|sqlite $DATABASE
+  echo "select '|'||port||'|' from used_ports;"|sqlite3 $DATABASE
   ;;
 
 getservers)
-  echo "select server,count(*) from sessions where status != 'F' group by server;"|sqlite $DATABASE
+  echo "select server,count(*) from sessions where status != 'F' group by server;"|sqlite3 $DATABASE
   ;;
 
 listsessions)
@@ -27,7 +27,7 @@ listsessions)
    substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),0,6)||substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),9,11),\
    uname,\
    strftime('%s','now','localtime') - strftime('%s',init_time),fs_port from  sessions  \
-   where status !='F' and server='$2' and uname='$UNAME' order by status desc;"|sqlite $DATABASE
+   where status !='F' and server='$2' and uname='$UNAME' order by status desc;"|sqlite3 $DATABASE
   ;;
 
 listsessions_all)
@@ -37,7 +37,7 @@ listsessions_all)
    substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),0,6)||substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),9,11),\
    uname,\
    strftime('%s','now','localtime') - strftime('%s',init_time),fs_port from  sessions  \
-   where status !='F' and uname='$UNAME' order by status desc;"|sqlite $DATABASE
+   where status !='F' and uname='$UNAME' order by status desc;"|sqlite3 $DATABASE
   ;;
 
 listsessionsroot)
@@ -52,7 +52,7 @@ listsessionsroot)
    substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),0,6)||substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),9,11),\
    uname,\
    strftime('%s','now','localtime') - strftime('%s',init_time),fs_port from  sessions  \
-   where server='$2'  order by status desc;"|sqlite $DATABASE
+   where server='$2'  order by status desc;"|sqlite3 $DATABASE
   ;;
 
 listsessionsroot_all)
@@ -67,7 +67,7 @@ listsessionsroot_all)
    substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),0,6)||substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),9,11),\
    uname,\
    strftime('%s','now','localtime') - strftime('%s',init_time),fs_port from  sessions  \
-   order by status desc;"|sqlite $DATABASE
+   order by status desc;"|sqlite3 $DATABASE
   ;;
 
 listsusp)
@@ -77,7 +77,7 @@ listsusp)
     exit  
   fi
   echo "select session_id, display, uname, server,round((strftime('%s','now','localtime') - strftime('%s',last_time))/60)\
-   from sessions where server='$2' and status='S';"|sqlite $DATABASE
+   from sessions where server='$2' and status='S';"|sqlite3 $DATABASE
   ;;
 
 listallrunning)
@@ -92,7 +92,7 @@ listallrunning)
    substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),0,6)||substr(strftime('%d.%m.%Y*%H:%M:%S',last_time),9,11),\
    uname,\
    strftime('%s','now','localtime') - strftime('%s',init_time),fs_port from  sessions  \
-   where status='R';"|sqlite $DATABASE
+   where status='R';"|sqlite3 $DATABASE
   ;;
 
 listmails)
@@ -104,7 +104,7 @@ listmails)
   echo "select user_messages.mess_id,sessions.session_id,\
       sessions.uname,sessions.display from sessions,user_messages,\
       messages where sessions.uname=user_messages.uname and sessions.status!='F'\
-      and messages.mess_id=user_messages.mess_id and sessions.server='$2';"|sqlite $DATABASE
+      and messages.mess_id=user_messages.mess_id and sessions.server='$2';"|sqlite3 $DATABASE
   ;;
 
 getmail)
@@ -113,7 +113,7 @@ getmail)
     echo "$UNAME, You have not permission to do this job!"
     exit  
   fi
-  echo "select message from messages where mess_id='$2';"|sqlite $DATABASE
+  echo "select message from messages where mess_id='$2';"|sqlite3 $DATABASE
   ;;
 
 rmmail)
@@ -122,7 +122,7 @@ rmmail)
     echo "$UNAME, You have not permission to do this job!"
     exit  
   fi
-  echo "delete from user_messages where mess_id='$2' and uname='$3';"|sqlite $DATABASE
+  echo "delete from user_messages where mess_id='$2' and uname='$3';"|sqlite3 $DATABASE
   ;;
 
 rmsessionsroot)
@@ -132,30 +132,30 @@ rmsessionsroot)
     exit  
   fi
   echo "delete from  sessions  \
-   where session_id='$2';"|sqlite $DATABASE
+   where session_id='$2';"|sqlite3 $DATABASE
   echo "delete from  used_ports  \
-   where session_id='$2';"|sqlite $DATABASE
+   where session_id='$2';"|sqlite3 $DATABASE
   ;;
 
 getagent)
-  echo "select agent_pid from sessions  where session_id = '$2';"|sqlite $DATABASE
+  echo "select agent_pid from sessions  where session_id = '$2';"|sqlite3 $DATABASE
   ;;
 
 getdisplay)
-  echo "select display from sessions  where session_id = '$2';"|sqlite $DATABASE
+  echo "select display from sessions  where session_id = '$2';"|sqlite3 $DATABASE
   ;;
 
 changestatus)
-  echo "update sessions set last_time=datetime('now','localtime'),status='$2' where session_id = '$3' and uname='$UNAME';"|sqlite $DATABASE
+  echo "update sessions set last_time=datetime('now','localtime'),status='$2' where session_id = '$3' and uname='$UNAME';"|sqlite3 $DATABASE
   ;;
 
 resume)
-  echo "update sessions set last_time=datetime('now','localtime'),status='R',client='$2' where session_id = '$3' and uname='$UNAME';"|sqlite $DATABASE
+  echo "update sessions set last_time=datetime('now','localtime'),status='R',client='$2' where session_id = '$3' and uname='$UNAME';"|sqlite3 $DATABASE
   ;;
 
 insertsession)
   OUTP=`echo "insert into sessions (display,server,uname,session_id, init_time, last_time) values \
-  ('$2','$3','$UNAME','$4', datetime('now','localtime'), datetime('now','localtime'));"|sqlite $DATABASE`
+  ('$2','$3','$UNAME','$4', datetime('now','localtime'), datetime('now','localtime'));"|sqlite3 $DATABASE`
   if [ "$OUTP" == "" ]
   then
     echo "INSERT 0 1"
@@ -164,12 +164,12 @@ insertsession)
 
 createsession)
   echo "update sessions set status='R',last_time=datetime('now','localtime'),cookie='$2',agent_pid='$3',\
-   client='$4',gr_port='$5',sound_port='$6',fs_port='$7' where session_id='$8' and uname='$UNAME';"|sqlite $DATABASE
+   client='$4',gr_port='$5',sound_port='$6',fs_port='$7' where session_id='$8' and uname='$UNAME';"|sqlite3 $DATABASE
   ;;
 
 insertport)
    OUTP=`echo "insert into used_ports (server,session_id,port) values \
-  ('$2','$3','$4');"|sqlite $DATABASE`
+  ('$2','$3','$4');"|sqlite3 $DATABASE`
   if [ "$OUTP" == "" ]
   then
     echo "INSERT 0 1"
@@ -178,7 +178,7 @@ insertport)
 
 insertmount)
    OUTP=`echo "insert into mounts (session_id,path,client) values \
-  ('$2','$3','$4');"|sqlite $DATABASE`
+  ('$2','$3','$4');"|sqlite3 $DATABASE`
   if [ "$OUTP" == "" ]
   then
     echo "INSERT 0 1"
@@ -186,11 +186,11 @@ insertmount)
   ;;
 
 deletemount)
-  echo "delete from mounts where session_id='$2' and path='$3';"|sqlite $DATABASE
+  echo "delete from mounts where session_id='$2' and path='$3';"|sqlite3 $DATABASE
   ;;
 
 getmounts)
-  echo "select client,path from mounts where session_id = '$2';"|sqlite $DATABASE
+  echo "select client,path from mounts where session_id = '$2';"|sqlite3 $DATABASE
   ;;
 
 *)
diff --git a/x2gosqlite.sh b/x2gosqlite.sh
index a42ecc1..fda8dfa 100755
--- a/x2gosqlite.sh
+++ b/x2gosqlite.sh
@@ -4,7 +4,7 @@ DATABASE=/var/db/x2go/x2go_sessions
 
 #rm $DATABASE
 
-echo "create table sessions(
+echo "create table if not exists sessions(
 		session_id varchar(500) primary key,
                 display integer not null, 
 		uname varchar(100) not null, 
@@ -19,36 +19,36 @@ echo "create table sessions(
 		sound_port int,
 		fs_port int,
 		unique(display)
-		);" | sqlite $DATABASE
+		);" | sqlite3 $DATABASE
 
 
-echo "create table messages(mess_id varchar(20) primary key, message text);" | sqlite $DATABASE
+echo "create table if not exists messages(mess_id varchar(20) primary key, message text);" | sqlite3 $DATABASE
 
-echo "create table user_messages(
+echo "create table if not exists user_messages(
                 mess_id varchar(20) not null, 
 		uname varchar(100) not null
-		);" | sqlite $DATABASE
+		);" | sqlite3 $DATABASE
 
 
-echo "create table used_ports(
+echo "create table if not exists used_ports(
                 server varchar(100) not null,
 		session_id varchar(500) references sessions on delete cascade, 
 		port integer primary key
-		);" | sqlite $DATABASE
+		);" | sqlite3 $DATABASE
 
-echo "create table mounts(
+echo "create table if not exists mounts(
                 session_id varchar(500) references sessions on delete restrict,
 		path varchar(512) not null, 
 		client inet not null, 
 		primary key(path,client)
-		);" | sqlite $DATABASE
+		);" | sqlite3 $DATABASE
 
-echo "CREATE TRIGGER fkd_mounts_session_id
+echo "CREATE TRIGGER if not exists fkd_mounts_session_id
 BEFORE DELETE ON sessions
 FOR EACH ROW BEGIN 
   SELECT CASE
     WHEN ((SELECT session_id FROM mounts WHERE session_id = OLD.session_id) IS NOT NULL)
     THEN RAISE(ABORT, 'delete on table \"sessions\" violates foreign key on table \"mounts\"')
   END;
-END;" | sqlite $DATABASE
+END;" | sqlite3 $DATABASE