set up dev environment

This commit is contained in:
Ray Elliott 2020-05-05 11:12:14 +01:00
parent 81bf00c8f6
commit cbfd69490c
3 changed files with 81 additions and 2 deletions

View File

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
. ./config . ./config
./dev/container-create.sh ./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"'

View File

@ -21,8 +21,10 @@ $_ssh_cmd_root 'a2enmod rewrite; systemctl restart apache2'
printf "\nSetting %s permissions ..." "$_user_www" printf "\nSetting %s permissions ..." "$_user_www"
$_ssh_cmd_root "echo \"$_user_www:$_passwd_www\" | chpasswd" $_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 '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 ..." printf "\nCreating database ..."
# database is insecure (no root password, remote root login, etc) - but not # database is insecure (no root password, remote root login, etc) - but not

73
dev/dev-env-setup.sh Executable file
View File

@ -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