Skip to content

Instantly share code, notes, and snippets.

@orimanabu
Last active August 29, 2015 14:18
Show Gist options
  • Save orimanabu/a9e67101978b8b7b477b to your computer and use it in GitHub Desktop.
Save orimanabu/a9e67101978b8b7b477b to your computer and use it in GitHub Desktop.
VNC server setup script for RHEL7/CentOS7
#!/bin/bash
if [ x"$#" != x"2" ]; then
echo "$0 username display"
exit 1
fi
user=$1; shift
display=$1; shift
unitfile=/etc/systemd/system/vncserver@:${display}.service
yum -y install tigervnc-server
homedir=$(getent passwd ${user} | cut -d: -f6)
dotvnc=${homedir}/.vnc
mkdir -p ${dotvnc}
vncpasswd passwd
mv passwd ${dotvnc}
chmod 600 ${dotvnc}
cp /lib/systemd/system/[email protected] ${unitfile}
sed -i.orig -e '/^[^#]/s/<USER>/root/g' ${unitfile}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment