Files
safe-x/userinit.sh.template
Ville Rantanen 514e6bd042 moved to ubuntu18
2019-02-14 11:51:00 +02:00

58 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
## THIS FILE gets overwritten!
USR=--USER--
addgroup --gid --USERGID-- $USR
useradd --uid --USERID-- --gid --USERGID-- -m $USR
echo "$USR ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
mkdir /home/$USR/.ssh /home/$USR/.vnc /home/$USR/bin
echo '--PUBKEY--' > /home/$USR/.ssh/authorized_keys
chmod 700 /home/$USR/.ssh
chmod 600 /home/$USR/.ssh/authorized_keys
chsh -s /bin/bash $USR
echo "#!/bin/bash
echo exit | nc -w 1 127.0.0.1 1515
" > /home/$USR/bin/exit-safe
chmod 755 /home/$USR/bin/*
cat <<'EOF' > /tools-install.sh
#!/bin/bash
test -f $HOME/.bashrc || sed 's,#force_color_prompt=yes,force_color_prompt=yes,' /etc/skel/.bashrc > $HOME/.bashrc
test -f $HOME/.profile || cp /etc/skel/.profile $HOME/.profile
echo "echo \$HOSTNAME | figlet" >> $HOME/.profile
echo "echo To exit and shutdown properly, type \'exit-safe\'" >> $HOME/.profile
mkdir -p $HOME/lib
mkdir -p $HOME/bin
mkdir -p $HOME/.config/autostart
pushd $HOME/lib > /dev/null
echo "Getting Tools repository"
ln -s /usr/local/share/q-tools tools
echo "Checking and adding tools/bin"
touch $HOME/.bash_cdhistory $HOME/.qcd
grep /lib/tools/rc $HOME/.bashrc > /dev/null || ( echo '. $HOME/lib/tools/rc' >> ~/.bashrc )
[[ -f $HOME/bin/xsessionrc ]] || {
cp $HOME/lib/tools/skel/xsessionrc $HOME/bin/xsessionrc
chmod 755 $HOME/bin/xsessionrc
}
[[ -f $HOME/.config/autostart/xsessionrc.desktop ]] || {
$HOME/lib/tools/bin/fimplate -e $HOME/lib/tools/skel/xsessionrc.desktop > $HOME/.config/autostart/xsessionrc.desktop
}
popd > /dev/null
EOF
chown -R $USR:$USR /home/$USR/
runuser -u $USR -- bash /tools-install.sh
echo "alias ff='firefox -no-remote &> /dev/null &'" >> /home/$USR/.bashrc
echo "alias cb='chromium-browser &> /dev/null &'" >> /home/$USR/.bashrc
chown -R $USR:$USR /home/$USR/