Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Last active February 4, 2023 09:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoudimus/d835c7d311e6f6ba9567 to your computer and use it in GitHub Desktop.
Save mahmoudimus/d835c7d311e6f6ba9567 to your computer and use it in GitHub Desktop.
intellij remote development with nomachine on ec2 ubuntu
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
add-apt-repository -y ppa:webupd8team/java
apt-get -qq update
apt-get install -y oracle-java8-installer xfce4 xvfb
wget http://download.nomachine.com/download/4.6/Linux/nomachine_4.6.4_13_amd64.deb
dpkg -i nomachine_4.6.4_13_amd64.deb
echo 'DefaultDesktopCommand "/usr/bin/X11/startxfce4"' >> /usr/NX/etc/server.cfg
echo "PhysicalDesktopAuthorization 0" >> /usr/NX/etc/server.cfg
echo "VirtualDesktopAuthorization 0" >> /usr/NX/etc/server.cfg
COOKIE=`ps -ef | md5sum | cut -f 1 -d " "`
AUTHFILE=$HOME/Xvfb-0.auth
xauth add :0 MIT-MAGIC-COOKIE-1 $COOKIE
# or custom resolution
Xvfb :0 -auth $AUTHFILE -screen 0 2048x1280x24 &
DISPLAY=:0 nohup /etc/X11/Xsession startxfce4 &
service nxserver restart
/usr/NX/bin/nxserver --install --setup-nomachine-key
useradd -m -d /home/mahmoud -s /bin/bash mahmoud
usermod -a -G admin mahmoud
passwd mahmoud
/usr/NX/bin/nxserver --useradd mahmoud
wget http://download.jetbrains.com/idea/ideaIU-14.1.4.tar.gz
tar xzvf ideaIU-14.1.4.tar.gz
cd ideaIU-14.1.14
JAVA_HOME/usr/lib/jvm/java-8-oracle ./bin/idea.sh
#!/bin/bash
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 4 | head -n 1)
ZONE=us-west1-c
NAME=button
option="$1"
PREEMPTIBLE="--preemptible"
case $option in
-p|--prod|--production)
unset PREEMPTIBLE
esac
gcloud compute instances create $NAME-$NEW_UUID \
--machine-type "n1-standard-1" \
--image "ubuntu-1604-xenial-v20180418" \
--image-project "ubuntu-os-cloud" \
--boot-disk-size "50" \
--boot-disk-type "pd-ssd" \
--boot-disk-device-name "$NEW_UUID" \
--zone $ZONE \
--labels ready=true \
--tags lucid \
$PROD \
--metadata startup-script='#! /bin/bash
sudo su -
apt-get update -y
apt-get install unzip -y
apt-get install python-setuptools -y
easy_install pip
pip install bottle
pip install google-cloud
pip install google-auth-httplib2
'
sleep 15
gcloud compute instances attach-disk $NAME-$NEW_UUID --disk $NAME-data --zone $ZONE
gcloud compute firewall-rules create fusion-appkit --allow tcp:8080
IP=$(gcloud compute instances describe $NAME-$NEW_UUID --zone us-central1-b | grep natIP | cut -d: -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
echo "Server started with $IP. Use the SSH button to login."
echo xfce4-session >~/.xsession
sudo apt-get install xrdp vnc4server git-core htop
sudo service xrdp restart
curl ifcfg.me
startx &
cat setup.sh
sudo install java
vncserver
vncserver -kill :1
vim ~/.vnc/xstartup
# /etc/xrdp/xrdp.ini
[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
#ip=127.0.0.1
ip=0.0.0.0
port=ask-1
[xrdp2]
name=sesman-X11rdp
lib=libxup.so
username=ask
password=ask
#ip=127.0.0.1
ip=0.0.0.0
port=ask-1
xserverbpp=24
################################################################
# Script_Name : Std-Xrdp-Install-0.1.sh
# Description : Perform an automated standard installation of xrdp
# on ubuntu 17.10
# Date : November 2017
# written by : Griffon
# Web Site :http://www.c-nergy.be - http://www.c-nergy.be/blog
# Version : 0.1
# Disclaimer : Script provided AS IS. Use it at your own risk....
##################################################################
#---------------------------------------------------#
# Step 0 - Try to Detect Ubuntu Version....
#---------------------------------------------------#
version=$(lsb_release -d | awk -F":" '/Description/ {print $2}')
if [ "$version" = " Ubuntu 17.10" ]
then
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mSupported version detected....proceeding\e[0m"
/bin/echo -e "\e[1;32mUbuntu Version :$version\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
else
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;31mYour system is not running Ubuntu 17.10 Edition.\e[0m"
/bin/echo -e "\e[1;31mThe script has been tested only on Ubuntu 17.10...\e[0m"
/bin/echo -e "\e[1;31mThe script is exiting...\e[0m"
/bin/echo -e "\e[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
exit
fi
#---------------------------------------------------#
# Step 1 - Install xRDP Software....
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mInstalling xrdp package....proceeding\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
sudo apt-get install xrdp -y
#---------------------------------------------------#
# Step 2 - Install Gnome Tweak Tool....
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mInstalling Gnome tweak package....proceeding\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
sudo apt-get install gnome-tweak-tool -y
#---------------------------------------------------#
# Step 3 - Allow console Access ....
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mGranting Console Access....proceeding\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
sudo sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config
#---------------------------------------------------#
# Step 4 - create policies exceptions ....
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mCreating Polkit file....proceeding\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
sudo bash -c 'cat >/etc/polkit-1/localauthority.conf.d/02-allow-colord.conf <<EOF
polkit.addRule(function(action, subject) {
if ((action.id == “org.freedesktop.color-manager.create-device” ||
action.id == “org.freedesktop.color-manager.create-profile” ||
action.id == “org.freedesktop.color-manager.delete-device” ||
action.id == “org.freedesktop.color-manager.delete-profile” ||
action.id == “org.freedesktop.color-manager.modify-device” ||
action.id == “org.freedesktop.color-manager.modify-profile”) &&
subject.isInGroup(“{group}”)) {
return polkit.Result.YES;
}
});
EOF'
#---------------------------------------------------#
# Step 5 - Enable Extensions ....
#---------------------------------------------------#
echo
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mEnabling Extensions....proceeding\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
gnome-shell-extension-tool -e ubuntu-dock@ubuntu.com
gnome-shell-extension-tool -e ubuntu-appindicators@ubuntu.com
#---------------------------------------------------#
# Step 6 - Credits ....
#---------------------------------------------------#
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
/bin/echo -e "\e[1;32mInstallation Completed\e[0m"
/bin/echo -e "\e[1;32mPlease test your xRDP configuration....\e[0m"
/bin/echo -e "\e[1;32mwritten by Griffon - November 2017 - Version 0.1 - Std-Xrdp-Install-0.1.sh\e[0m"
/bin/echo -e "\e[1;32m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\e[0m"
echo
#!/bin/sh
# belongs in ~/.vnc/xstartup
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
xrdb $HOME/.Xresources
xsetroot -solid grey
startxfce4 &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment