From cbfd69490ccf92852fe709654e0d182bfad84c7f Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 5 May 2020 11:12:14 +0100 Subject: [PATCH] set up dev environment --- container-setup.sh | 6 +++- dev/container-create.sh | 4 ++- dev/dev-env-setup.sh | 73 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 dev/dev-env-setup.sh diff --git a/container-setup.sh b/container-setup.sh index 4f5031f..bb08296 100755 --- a/container-setup.sh +++ b/container-setup.sh @@ -1,6 +1,10 @@ #!/bin/sh . ./config + ./dev/container-create.sh - +_url="$_local_hostname.$_local_domain" +cat config dev/dev-env-setup.sh | ssh root@"$_url" 'cat >/tmp/deploy-script.sh' +ssh root@"$_url" '/bin/bash /tmp/deploy-script.sh' +ssh root@"$_url" '/bin/bash -c "rm /tmp/deploy-script.sh"' diff --git a/dev/container-create.sh b/dev/container-create.sh index 185d04b..0ace5aa 100755 --- a/dev/container-create.sh +++ b/dev/container-create.sh @@ -21,8 +21,10 @@ $_ssh_cmd_root 'a2enmod rewrite; systemctl restart apache2' printf "\nSetting %s permissions ..." "$_user_www" $_ssh_cmd_root "echo \"$_user_www:$_passwd_www\" | chpasswd" +# TODO $_user_www 's home directory is hardcoded here - should maybe make it +# into a variable $_ssh_cmd_root 'sed -i '\''s+www-data:/var/www:/usr/sbin/nologin+www-data:/var/www:/bin/bash+'\'' /etc/passwd' -$_ssh_cmd_root 'chown -R www-data: /var/www/html' +$_ssh_cmd_root 'chown -R www-data: /var/www' printf "\nCreating database ..." # database is insecure (no root password, remote root login, etc) - but not diff --git a/dev/dev-env-setup.sh b/dev/dev-env-setup.sh new file mode 100755 index 0000000..58e27dd --- /dev/null +++ b/dev/dev-env-setup.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +_home_dir="/var/www" +_config_dir="$_home_dir/.config" + +mkdir -p "$_config_dir" +chown "$_user_www": "$_config_dir" + +echo "installing lf ..." +_download_url="https://github.com/gokcehan/lf/releases/download/$_lf_version/lf-linux-amd64.tar.gz" +wget "$_download_url" -O /tmp/lf.tar.gz +tar -xzvf /tmp/lf.tar.gz -C /usr/local/bin/ +git clone 'https://git.rayelliott.dev/dots/lf.git' "$_config_dir/lf" + + +cd /tmp +wget https://nodejs.org/dist/"$_node_version"/node-"$_node_version"-"$_node_distro".tar.xz +mkdir -p /usr/local/lib/nodejs +tar -xJvf node-"$_node_version"-"$_node_distro".tar.xz -C /usr/local/lib/nodejs +echo "PATH=/usr/local/lib/nodejs/node-$_node_version-$_node_distro/bin:$PATH" >> "$_home_dir"/.profile +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list +apt-get update && apt-get -y install yarn + + +apt-get -y install ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip python-pip python3-pip tig fzf +cd /tmp +git clone https://github.com/neovim/neovim +cd neovim +make CMAKE_BUILD_TYPE=Release +mkdir -p /usr/local/share/nvim +mv /tmp/neovim/runtime /usr/local/share/nvim/runtime + mv /tmp/neovim/build/bin/nvim /usr/local/bin/nvim + + +cd "$_home_dir" +su "$_user_www" -c "git clone https://git.rayelliott.dev/dots/nvim.git $_config_dir/nvim" +su "$_user_www" --login -c 'yarn global add neovim' +su "$_user_www" --login -c 'python2 -m pip install --user --upgrade pynvim' +su "$_user_www" --login -c 'python3 -m pip install --user --upgrade pynvim' +su "$_user_www" --login -c 'nvim --headless +PlugInstall +qall' + + +# locale +if [ -f /etc/locale.gen ] && command -v locale-gen ; then + echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen + locale-gen + echo 'LANG="en_GB.UTF-8"' > /etc/default/locale +else + echo 'Warning can not set locale' +fi + + +apt-get -y install tmux git +su "$_user_www" -c "git clone https://git.rayelliott.dev/dots/tmux.git $_config_dir/tmux" +su "$_user_www" -c "ln -bfs $_config_dir/tmux/tmux.conf $_home_dir/.tmux.conf" +su "$_user_www" -c "ln -bfs /$_config_dir/tmux/tmux $_home_dir/.tmux" +su "$_user_www" -c "ln -bfs /$_config_dir/tmux/tmux.colours-base16.conf $_config_dir/tmux/tmux.colours.conf" + + +apt-get -y install zsh git +mkdir -p "$HOME"/.config +cd "$HOME" +rm -Rf .config/zsh +su "$_user_www" -c 'git clone https://git.rayelliott.dev/dots/zsh.git /var/www/.config/zsh' +su "$_user_www" -c 'git clone https://github.com/tarjoilija/zgen.git /var/www/.config/zsh/zgen' +su "$_user_www" -c 'ln -bfs /var/www/.config/zsh/zshrc /var/www/.zshrc' + +# set interactive shell +_zsh=$(command -v zsh) +if [ -f "$_zsh" ] ; then + chsh "$_user_www" -s "$_zsh" +fi