Commit 9b61c946 by x

Merge branch 'master' of ssh://giccero.cloud.ik.bme.hu/cloud

parents 6912709b 071a43bd
#Install
cp rdp.sh /usr/local/bin/rdp
cp enc.pl /usr/local/bin/enc.pl
cp rdp.desktop ~/.local/share/applications/
### Ezt lehet hogy érdemesebb kézzel vagy echo >> mlg kiderül
cp mimeapps.list ~/.local/share/applications/
#http://www.nomachine.com/ar/view.php?ar_id=AR01C00125
use strict;
use Time::localtime;
$::numValidCharList = 85;
$::dummyString = "{{{{";
#
#FOR TEST
#
my $password = @ARGV[0];
print $password,"\n";
my $scrambled_string = scrambleString($password);
print $scrambled_string,"\n";
sub getvalidCharList
{
my $pos = shift;
my @validCharList =
(
"!", "#", "\$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}"
);
return $validCharList[$pos];
}
sub encodePassword
{
my $p = shift;
my $sPass = ":";
my $sTmp = "";
if (!$p)
{
return "";
}
for (my $i = 0; $i < length($p); $i++)
{
my $c = substr($p,$i,1);
my $a=ord($c);
$sTmp=($a+$i+1).":";
$sPass .=$sTmp;
$sTmp = "";
}
return $sPass;
}
sub findCharInList
{
my $c = shift;
my $i = -1;
for (my $j = 0; $j < $::numValidCharList; $j++)
{
my $randchar = getvalidCharList($j);
if ($randchar eq $c)
{
$i = $j;
return $i;
}
}
return $i;
}
sub getRandomValidCharFromList
{
my $tm = localtime;
my $k = ($tm->sec);
return getvalidCharList($k);
}
sub scrambleString
{
my $s = shift;
my $sRet = "";
if (!$s)
{
return $s;
}
my $str = encodePassword($s);
if (length($str) < 32)
{
$sRet .= $::dummyString;
}
for ( my $iR = (length($str) - 1); $iR >= 0; $iR--)
{
#
#Reverse string.
#
$sRet .= substr($str,$iR,1);
}
if (length($sRet) < 32)
{
$sRet .= $::dummyString;
}
my $app=getRandomValidCharFromList();
my $k=ord($app);
my $l=$k + length($sRet) -2;
$sRet= $app.$sRet;
for (my $i1 = 1; $i1 < length($sRet); $i1++)
{
my $app2=substr($sRet,$i1,1);
my $j = findCharInList($app2);
if ($j == -1)
{
return $sRet;
}
my $i = ($j + $l * ($i1 + 1)) % $::numValidCharList;
my $car=getvalidCharList($i);
$sRet=substr_replace($sRet,$car,$i1,1);
}
my $c = (ord(getRandomValidCharFromList())) + 2;
my $c2=chr($c);
$sRet=$sRet.$c2;
return URLEncode($sRet);
}
sub URLEncode
{
my $theURL = $_[0];
$theURL =~ s/&/&amp;/g;
$theURL =~ s/\"\"/&quot;/g;
$theURL =~ s/\'/&#039;/g;
$theURL =~ s/</&lt;/g;
$theURL =~ s/>/&gt;/g;
return $theURL;
}
sub substr_replace
{
my $str = shift;
my $ch = shift;
my $pos = shift;
my $qt = shift;
my @list = split (//,$str);
my $count = 0;
my $tmp_str = '';
foreach my $key(@list)
{
if ($count != $pos)
{
$tmp_str .= $key;
}
else
{
$tmp_str .= $ch;
}
$count++;
}
return $tmp_str;
}
[Added Associations]
application/nx-session=gedit.desktop;
x-scheme-handler/rdp=rdp.desktop
x-scheme-handler/nx=rdp.desktop
[Default Applications]
text/html=chromium-browser.desktop
x-scheme-handler/http=chromium-browser.desktop
x-scheme-handler/https=chromium-browser.desktop
x-scheme-handler/about=chromium-browser.desktop
x-scheme-handler/unknown=chromium-browser.desktop
[Desktop Entry]
Name=RDP Client
Exec=/usr/local/bin/rdp %u
Icon=
Type=Application
Terminal=false
MimeType=x-scheme-handler/rdp;
#!/bin/bash
IFS=: read scheme user password host port<<<"$*"
case $scheme in
rdp)
tmp=$(mktemp)
rdesktop -khu -E -P -0 -f -u "$user" -p "$password" "$host":"$port" 2>$tmp
if grep '^ERROR' <$tmp
then
err="$(grep '^ERROR' $tmp)"
rm /home/user/.ssh/known_hosts
/usr/NX/bin/nxclient --dialog error --message "$err" &
fi
rm $tmp
;;
nx)
f=$(mktemp)
#pw=$(perl /usr/local/bin/enc.pl "$password"|tail -1|sed -e 's/\&/\&amp;/g' -e 's/</\&lt;/g' -e 's/"/&quot;/g' -e "s/'/\&apos;/g")
pw=$(perl /usr/local/bin/enc.pl "$password"|tail -1)
cat >"$f" <<A
<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="Advanced" >
<option key="Cache size" value="16" />
<option key="Cache size on disk" value="64" />
<option key="Current keyboard" value="true" />
<option key="Custom keyboard layout" value="" />
<option key="Disable DirectDraw" value="false" />
<option key="Disable ZLIB stream compression" value="false" />
<option key="Disable deferred updates" value="false" />
<option key="Enable HTTP proxy" value="false" />
<option key="Enable SSL encryption" value="true" />
<option key="Enable response time optimisations" value="false" />
<option key="Grab keyboard" value="false" />
<option key="HTTP proxy host" value="" />
<option key="HTTP proxy port" value="8080" />
<option key="HTTP proxy username" value="" />
<option key="Remember HTTP proxy password" value="false" />
<option key="Restore cache" value="true" />
<option key="StreamCompression" value="" />
</group>
<group name="Environment" >
<option key="CUPSD path" value="/usr/sbin/cupsd" />
</group>
<group name="General" >
<option key="Automatic reconnect" value="true" />
<option key="Command line" value="" />
<option key="Custom Unix Desktop" value="console" />
<option key="Desktop" value="gnome" />
<option key="Disable SHM" value="false" />
<option key="Disable emulate shared pixmaps" value="false" />
<option key="Link speed" value="lan" />
<option key="Remember password" value="true" />
<option key="Resolution" value="fullscreen" />
<option key="Resolution height" value="600" />
<option key="Resolution width" value="800" />
<option key="Server host" value="${host}" />
<option key="Server port" value="${port}" />
<option key="Session" value="unix" />
<option key="Spread over monitors" value="false" />
<option key="Use default image encoding" value="0" />
<option key="Use render" value="true" />
<option key="Use taint" value="true" />
<option key="Virtual desktop" value="false" />
<option key="XAgent encoding" value="true" />
<option key="displaySaveOnExit" value="true" />
<option key="xdm broadcast port" value="177" />
<option key="xdm list host" value="localhost" />
<option key="xdm list port" value="177" />
<option key="xdm mode" value="server decide" />
<option key="xdm query host" value="localhost" />
<option key="xdm query port" value="177" />
</group>
<group name="Images" >
<option key="Disable JPEG Compression" value="0" />
<option key="Disable all image optimisations" value="false" />
<option key="Disable backingstore" value="false" />
<option key="Disable composite" value="false" />
<option key="Image Compression Type" value="3" />
<option key="Image Encoding Type" value="0" />
<option key="Image JPEG Encoding" value="false" />
<option key="JPEG Quality" value="6" />
<option key="RDP Image Encoding" value="3" />
<option key="RDP JPEG Quality" value="6" />
<option key="RDP optimization for low-bandwidth link" value="false" />
<option key="Reduce colors to" value="" />
<option key="Use PNG Compression" value="true" />
<option key="VNC JPEG Quality" value="6" />
<option key="VNC images compression" value="3" />
</group>
<group name="Login" >
<option key="Auth" value="${pw}" />
<option key="Guest Mode" value="false" />
<option key="Guest password" value="" />
<option key="Guest username" value="" />
<option key="Login Method" value="nx" />
<option key="User" value="${user}" />
</group>
<group name="Services" >
<option key="Audio" value="false" />
<option key="IPPPort" value="631" />
<option key="IPPPrinting" value="false" />
<option key="Shares" value="false" />
</group>
<group name="VNC Session" >
<option key="Display" value="0" />
<option key="Remember" value="false" />
<option key="Server" value="" />
</group>
<group name="Windows Session" >
<option key="Application" value="" />
<option key="Authentication" value="2" />
<option key="Color Depth" value="8" />
<option key="Domain" value="" />
<option key="Image Cache" value="true" />
<option key="Password" value="EMPTY_PASSWORD" />
<option key="Remember" value="true" />
<option key="Run application" value="false" />
<option key="Server" value="" />
<option key="User" value="" />
</group>
<group name="share chosen" >
<option key="Share number" value="0" />
</group>
</NXClientSettings>
A
/usr/NX/bin/nxclient --session $f
;;
ssh)
#/usr/NX/bin/nxclient --dialog ok --message "Jelszó: $password" &
rm /home/user/.ssh/known_hosts
#rxvt-unicode -e sh -c "ssh $user@$host -p$port; sleep 2"
rxvt-unicode -e sh -c "sshpass -p "$password" ssh -o StrictHostKeyChecking=no $user@$host -p$port; sleep 2"
;;
*)
xmessage "$scheme is not supported."
;;
esac
echo "$*" >>/tmp/protolog
......@@ -23,7 +23,10 @@ a:link,a:visited{
margin:0;
padding:5px;
}
.contentblock ul{
.contentblock{
list-style: none;
}
.wm-list{
list-style: none;
}
......@@ -102,14 +105,23 @@ a:link,a:visited{
background-image: url(icons/animal-penguin.png)
}
.wm .details .type{
background-image: url(icons/processor.png)
background-image: url(icons/box-share.png)
}
.wm .details .date{
background-image: url(icons/calendar-day.png)
}
.wm .details .cpu{
background-image: url(icons/processor.png)
}
.wm .details .memory{
background-image: url(icons/memory.png)
}
.wm .details .value{
float: right;
}
.wm .details a{
text-decoration: underline;
}
.wm .summary:hover{
background-color: #b1b1b1;
}
......@@ -181,7 +193,7 @@ a:link,a:visited{
.filetype-up {
background-image: url(icons/upload-cloud.png);
}
#new-wm-button .name{
.wm.new .name{
background-image: url(icons/computer--plus.png);
}
.wm-on{
......@@ -190,46 +202,15 @@ a:link,a:visited{
.wm-off{
background-image: url(icons/computer-off.png);
}
table
{
background-color:#ccc;
border-radius:10px;
margin:5px;
.wm-list.modal{
border-radius: 4px;
border: 1px solid #666;
}
td,th
{
border-bottom:1px solid #bbb;
vertical-align:top;
padding:5px;
.wm-list.modal input{
padding: 2px 10px;
}
table input,table select,table textarea
{
min-width:300px;
border:1px solid #aaa;
display:block;
}
input[type=submit],.button,.smallbutton
{
background-color:#072c61;
text-decoration:none;
color:#fff!important;
border:2px solid #fff;
border-radius:10px;
min-width:5em;
font-size:.9em;
line-height:.9em;
font-weight:700;
margin:0;
padding:5px;
}
.smallbutton
{
padding:1px 5px;
.wm-list.modal .wm:nth-child(1) .summary{
border-top: none;
}
p.rightbuttons
......@@ -519,4 +500,6 @@ ul.errorlist,td ul.errorlist
background-color: #fff;
border-radius: 4px;
padding: 20px;
box-shadow: 0 0 30px rgba(0,0,0,0.4);
border: 1px solid #333;
}
\ No newline at end of file
......@@ -4,30 +4,36 @@
<html lang="{{lang}}">
<head>
<title>{% block title %}IK Cloud{% endblock %}</title>
<link href='http://fonts.googleapis.com/css?family=Metrophobic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/static/style.css" />
<link rel="icon" type="image/png" href="/static/favicon.png" />
<link rel="icon" type="image/png" href="one/static/favicon.png">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="/static/jquery.min.js"></script>
<script type="text/javascript">
<link rel="icon" type="image/png" href="one/static/favicon.png">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="/static/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.wm .summary').click(function(){
if($(this).next('.details').is(':hidden')){
$('.wm .summary').each(function(){
this.originalHeight=parseInt($(this).next('.details').css('height'));
})
var toggleDetails=function(){
if($(this).next('.details').is(':hidden')){
$(this).next('.details')
.css('height',0)
.css('padding','0px 5px')
.show()
.animate({height:160,paddingTop:15,paddingBottom:15},700);
.animate({height:this.originalHeight,paddingTop:15,paddingBottom:15},700);
} else {
var that=this;
$(this).next('.details')
.css('height',130)
//2*15px paddingot le kell vonni, a jQuery szar
.css('height',this.originalHeight-30)
.css('padding','15px 5px')
.animate({height:0,paddingTop:0,paddingBottom:0},700,function(){
$(that).next('.details').hide();
});
}
})
}
$('.wm .summary').click(toggleDetails);
$('#load-more-files').click(function(){
$('.actions', this).show();
var that=this;
......@@ -40,6 +46,10 @@ $(function(){
$('#new-wm-button').click(function(){
$('#modal').show();
$('#modal-container').html($('#new-wm').html());
$('#modal-container .wm .summary').each(function(){
this.originalHeight=parseInt($(this).next('.details').css('height'));
})
$('#modal-container .wm .summary').click(toggleDetails);
});
$('#shadow').click(function(){
$('#modal').hide();
......
......@@ -4,7 +4,7 @@
<div class="summary">
<!--<div class="id">161</div>-->
<div class="name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}">
<a href="/vm/show/{{i.id}}/" title="{{i.name}}">{{i.name|truncatechars:20}}</a>
{{i.name|truncatechars:20}}
</div>
<div class="status">
{{i.state}}
......@@ -36,6 +36,7 @@
<li class="os-linux">Operációs rendszer: <span class="value">{{i.template.disk.name}}</span></li>
<li class="type">Instance típus: <span class="value">{{i.template.instance_type.name}}</span></li>
<li class="date">Létrehozás dátuma: <span class="value">{{i.created_at}}</span></li>
<li>&nbsp;<span class="value"><a href="/vm/show/{{i.id}}/" title="{{i.name}}">További részletek</a></span></li>
</ul>
</div>
</li>
......
......@@ -3,26 +3,88 @@
{% block content %}
<div class="boxes">
<div class="contentblock" id="state">
<h2>Virtuális gépek</h2>
<ul class="wm-list">
{% include "box-vmlist.html" %}
<li id="new-wm-button" class="wm">
<div class="summary">
<div class="name">Új gép indítása</div>
<div class="clear"></div>
</div>
</li>
<li id="new-wm" style="display: none">
<h2>Rendelkezésre álló sablonok</h2>
<div class="contentblock" id="state">
<h2>Virtuális gépek</h2>
<ul class="wm-list">
{% include "box-vmlist.html" %}
<li id="new-wm-button" class="wm new">
<div class="summary">
<div class="name">Új gép indítása</div>
<div class="clear"></div>
</div>
</li>
<li id="new-wm" style="display: none">
<h2>Rendelkezésre álló sablonok</h2>
<ul class="wm-list modal">
{% for m in templates %}
<li class="wm">
<form method="POST" action="/vm/new/{{m.pk}}/">{% csrf_token %}
<p><input type="submit" value="{{m.name}}" class="button widebutton"/></p>
<div class="summary">
<div class="name wm-on">{{m.name}}</div>
<div class="status">
<input type="submit" value="Indítás"/>
</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>
Részletek
</h3>
<ul>
<li class="name">Rendszer: <span class="value">{{m.disk.name}}</span></li>
<li class="type">Instance típus: <span class="value">{{m.instance_type.name}}</span></li>
<li class="memory">Memória: <span class="value">{{m.instance_type.RAM}} MiB</span></li>
<li class="cpu">CPU magok: <span class="value">{{m.instance_type.CPU}}</span></li>
</ul>
</div>
</form>
</li>
{% endfor %}
</li>
</ul>
</div>
</ul>
</li>
</ul>
</div>
<div class="contentblock" id="template">
<h2>Saját sablonok</h2>
<ul class="wm-list">
{ include "box-templatelist.html" lesz majd itt }
<li id="new-template-button" class="wm new">
<div class="summary">
<div class="name">Új Sablon</div>
<div class="clear"></div>
</div>
</li>
<li id="new-template" style="display: none">
<h2>Rendelkezésre álló sablonok</h2>
<ul class="wm-list modal">
{% for m in templates %}
<li class="wm">
<form method="POST" action="/vm/new/{{m.pk}}/">{% csrf_token %}
<div class="summary">
<div class="name wm-on">{{m.name}}</div>
<div class="status">
<input type="submit" value="Indítás"/>
</div>
<div class="clear"></div>
</div>
<div class="details">
<h3>
Részletek
</h3>
<ul>
<li class="name">Rendszer: <span class="value">{{m.disk.name}}</span></li>
<li class="type">Instance típus: <span class="value">{{m.instance_type.name}}</span></li>
<li class="memory">Memória: <span class="value">{{m.instance_type.RAM}} MiB</span></li>
<li class="cpu">CPU magok: <span class="value">{{m.instance_type.CPU}}</span></li>
</ul>
</div>
</form>
</li>
{% endfor %}
</ul>
</li>
</ul>
</div>
{% for box in boxes %}
{% if forloop.counter0|divisibleby:2 %}
<div class="contentblock">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment