Last active
June 20, 2021 17:16
-
-
Save Gedevan-Aleksizde/a92dfa9c0be9d6315108ffe013c8f980 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
sudo apt install -yqq ./rstudio.deb | |
MKRUNUSERDIR_PATH="/usr/sbin/wsl-user-mk-runuserdir" | |
set -e | |
cat > ${MKRUNUSERDIR_PATH} << \EOF | |
### User runtime dir | |
# Executed as part of 00-wsl-user-env.sh | |
RUNUSER_DIR="/run/user" | |
UID=$(id -u ${SUDO_USER}) | |
sudo mkdir -m 0700 -p ${RUNUSER_DIR}/${UID} | |
sudo chown ${UID}:${UID} ${RUNUSER_DIR}/${UID} | |
EOF | |
chmod +x ${MKRUNUSERDIR_PATH} | |
echo "%sudo ALL = NOPASSWD: ${MKRUNUSERDIR_PATH}" >\ | |
"/etc/sudoers.d/$(basename wsl-user-mk-runuserdir)" | |
echo "$MKRUNUSERDIR_PATH created." | |
WSL_USER_ENV_FILE="/etc/profile.d/00-wsl-user-env.sh" | |
cat > ${WSL_USER_ENV_FILE} << \EOF | |
### Global GUI app support ENV. | |
# Adjust SCALE_FACTOR as needed. | |
set -a | |
DISPLAY="$(ip r l default | cut -d\ -f3):0.0" | |
XDG_RUNTIME_DIR=/run/user/${UID} | |
GDK_SCALE="1.2" | |
NO_AT_BRIDGE="1" | |
QT_SCALE_FACTOR="1.2" | |
QT_X11_NO_MITSHM="1" | |
set +a | |
sudo /usr/sbin/wsl-user-mk-runuserdir | |
EOF | |
echo "${WSL_USER_ENV_FILE} created" | |
echo 'export LIBGL_ALWAYS_INDIRECT=1' >> /home/${SUDO_USER}/.profile | |
echo "An environment variable added at /home/${SUDO_USER}/.profile" | |
# setup fcitx-mozc | |
# Ref: https://qnighy.hatenablog.com/entry/2017/10/01/220000 | |
echo 'installing fcitx...' | |
sudo apt install -yqq fcitx-mozc fcitx-frontend-qt5 | |
sudo apt remove -yqq ibus | |
echo "setting environment variables into /home/${SUDO_USER}/.profile" | |
echo "export QT_IM_MODULE=fcitx" >> /home/${SUDO_USER}/.profile | |
echo "export GTK_IM_MODULE=fcitx" >> /home/${SUDO_USER}/.profile | |
echo "export XMODIFIERS=@im=fcitx" >> /home/${SUDO_USER}/.profile | |
echo "export DefaultIMModule=fcitx" >> /home/${SUDO_USER}/.profile | |
echo "fcitx-autostart" >> /home/${SUDO_USER}/.profile | |
echo "inserting settings into /home/${SUDO_USER}/.config/RStudio/desktop.ini" | |
cp /home/${SUDO_USER}/.config/RStudio/desktop.ini /home/${SUDO_USER}/.config/RStudio/desktop.ini.bak | |
sed '/^\[General\]$/a desktop.renderingEngine=software' /home/${SUDO_USER}/.config/RStudio/desktop.ini.bak > /home/${SUDO_USER}/.config/RStudio/desktop.ini | |
echo "copy libfcitxplatforminputcontextplugin.so to Rstudio directory." | |
sudo ln -s /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so /usr/lib/rstudio/plugins/platforminputcontexts/ | |
echo "installation finished" | |
set +e | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
set -e | |
echo "Intstallation Started" | |
echo "---- set locale ----" | |
sudo apt update -qq | |
sudo apt install -yqq language-pack-ja manpages-ja manpages-ja-dev | |
sudo update-locale LANG=ja_JP.UTF-8 | |
# タイムゾーン変更. 自分の環境では最初から日本時間だったが念の為 | |
sudo echo "Asia/Tokyo" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata | |
platform_codename=$(lsb_release -sc) | |
if [ $platform_codename != "focal" ] ; then | |
echo "WARNING: This script is written for Ubuntu 20.04 (focal). Your version is ${platform_codename}. This script may occur unexpected problem." | |
fi | |
# いろいろな操作に影響するプログラムのインストール | |
sudo apt install -yqq gdebi-core build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev || ( echo "requirements installation failed"; exit -1 ) | |
echo "---- install base R ----" | |
if ! [ -x "$(command -v R)" ]; then | |
sudo apt install -yqq --no-install-recommends software-properties-common dirmngr | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 | |
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu ${platform_codename}-cran40/" | |
sudo apt update | |
sudo apt install -yqq --no-install-recommends r-base | |
else | |
echo "R is already installed. This procedure skipped" | |
fi | |
# RStudio のインストール | |
echo "---- install RStudio Server ----" | |
if ! [ -x "$(command -v rstudio-server)" ]; then | |
wget "https://rstudio.org/download/latest/stable/server/bionic/rstudio-server-latest-amd64.deb" | |
sudo apt install -yqq ./rstudio-server-latest-amd64.deb | |
else | |
echo "RStudio Server is already installed. This procedure skipped" | |
fi | |
echo "---- install Depedendencies ----" | |
# 日本語対応フォント | |
sudo apt install -yqq fonts-noto-cjk fonts-noto-color-emoji # 一応絵文字も | |
# sudo apt install -yqq fonts-noto-cjk-extra # こっちは必須でない, ウエイト違いのフォントが欲しい場合のみ | |
fc-cache -fv | |
# ragg 等グラフィックに必要 | |
# 実は Ubuntu なら ragg がなくてもグラフの文字化けは起こりにくい | |
sudo apt install -yqq libfontconfig1-dev | |
sudo apt install -yqq libharfbuzz-dev libfribidi-dev | |
sudo apt install -yqq libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev | |
# rsvg に必要 | |
sudo apt install -yqq librsvg2-dev | |
# units に必要 | |
sudo apt install -yqq libudunits2-dev | |
# 画像加工で広く利用 | |
sudo apt install -yqq libmagick++-dev | |
# gifski に必要 | |
sudo apt install -yqq cargo | |
# sf 等 GIS 関連 | |
sudo apt install -yqq libgdal-dev libgeos-dev | |
# rstan に必要 (正確には依存パッケージのV8に必要) | |
sudo apt install -yqq libv8-dev libnode-dev # おそらくどちらかが自動で選択される | |
# rgl | |
sudo apt install -yqq mesa-common-dev libglu1-mesa-dev | |
# DiagrammeR とか | |
sudo apt install -yqq graphviz | |
# R MarkdownでPDFを作成するときに必要になるかも | |
sudo apt install -yqq libpoppler-cpp-dev | |
echo "Installation finieshed. Please restart Ubuntu" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment