Browse Source

Merge pull request #13 from fp9695253/master

Add virtual environment installation step, make users passwordless sudoer
master
Charles Reid 6 years ago committed by GitHub
parent
commit
04b44a3e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      tasks_sudo/get_docker.sh
  2. 14
      tasks_sudo/get_docker_compose.sh
  3. 4
      tasks_sudo/make_user.sh
  4. 10
      tasks_sudo/sudo_init.sh
  5. 39
      tasks_user/install_virtualenv.py
  6. 1
      tasks_user/user_init.sh

9
tasks_sudo/get_docker.sh

@ -1,5 +1,14 @@ @@ -1,5 +1,14 @@
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo ""
echo ""
echo "This script should be run as root."
echo ""
echo ""
exit 1;
fi
bash <( curl https://get.docker.com/ )
usermod -aG docker ubuntu

14
tasks_sudo/get_docker_compose.sh

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo ""
echo ""
echo "This script should be run as root."
echo ""
echo ""
exit 1;
fi
curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

4
tasks_sudo/make_user.sh

@ -14,7 +14,7 @@ fi @@ -14,7 +14,7 @@ fi
set -x
USERNAME="matomo"
USERNAME="florence"
sudo mkdir -p /home/${USERNAME}
@ -22,6 +22,8 @@ sudo useradd -s /bin/bash -d /home/$USERNAME $USERNAME @@ -22,6 +22,8 @@ sudo useradd -s /bin/bash -d /home/$USERNAME $USERNAME
sudo usermod -a -G ubuntu $USERNAME
sudo usermod -a -G sudo $USERNAME
echo "${REGUSER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${REGUSER}
# copy the user init script
sudo wget https://raw.githubusercontent.com/dahak-metagenomics/dahak-yeti/master/tasks_user/user_init.sh -O /home/$USERNAME/user_init.sh
sudo chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}

10
tasks_sudo/sudo_init.sh

@ -1,5 +1,14 @@ @@ -1,5 +1,14 @@
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo ""
echo ""
echo "This script should be run as root."
echo ""
echo ""
exit 1;
fi
if [[ "$#" -eq 1 ]]
then
@ -14,6 +23,7 @@ then @@ -14,6 +23,7 @@ then
./gen_ssh_keys.sh
./set_machine_name.sh $1
./get_docker.sh
./get_docker_compose.sh
./make_temp.sh
./install_singularity.sh &> /tmp/install_singularity_log

39
tasks_user/install_virtualenv.py

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
#!/usr/bin/env python3
import os, sys
import getpass
import tempfile
import subprocess
"""
Install Virtualenv
"""
def install_venv():
user = getpass.getuser()
if(user=="root"):
raise Exception("You are root - you should run this script as a normal user.")
else:
print("Installing snakemake...")
pyenvbin = os.environ['HOME']
condabin = pyenvbin+"/.pyenv/shims/conda"
pipbin = pyenvbin+"/.pyenv/shims/pip"
print(" - Installing virtualenv")
rc = subprocess.call([pipbin,"install","virtualenv"])
if(rc != 0):
raise Exception()
print(" ~~*~~ ~~*~~ ~~*~~ SUCCESS! ~~*~~ ~~*~~ ~~*~~\n")
print(" Snakemake is now installed.")
print(" Test that snakemake is working using the following one-liner:\n")
print(" virtualenv vp && rm -fr vp")
print()
if __name__=="__main__":
install_venv()

1
tasks_user/user_init.sh

@ -19,4 +19,5 @@ cd ../ @@ -19,4 +19,5 @@ cd ../
./install_pyenv.py
. ~/.bash_profile
./activate_conda.py
./install_virtualenv.py
./install_snakemake.py

Loading…
Cancel
Save