Skip to content

Commit

Permalink
[update]mod install scripts for Arch Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkenpa198 committed Mar 9, 2024
1 parent 3ae8b54 commit 12b154e
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install dotfiles on Ubuntu
run: bash setup/ubuntu/setup.sh
run: bash setup/linux/setup.sh
25 changes: 12 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@
!app/WindowsTerminal/LocalState/settings.json

!setup/macos/Brewfile
!setup/ubuntu/install-apt-packages.sh
!setup/ubuntu/install-git.sh
!setup/ubuntu/install-jekyll.sh
!setup/ubuntu/install-language-pack-ja.sh
!setup/ubuntu/install-my-scripts.sh
!setup/ubuntu/install-node-js.sh
!setup/ubuntu/install-pyenv.sh
!setup/ubuntu/install-rbenv.sh
!setup/ubuntu/install-vscode-extensions.sh
!setup/ubuntu/install-sheldon.sh
!setup/ubuntu/link.sh
!setup/ubuntu/setup.sh
!setup/ubuntu/setup-ja.sh
!setup/linux/install-packages.sh
!setup/linux/install-jekyll.sh
!setup/linux/install-language-pack-ja.sh
!setup/linux/install-my-scripts.sh
!setup/linux/install-node-js.sh
!setup/linux/install-pyenv.sh
!setup/linux/install-rbenv.sh
!setup/linux/install-vscode-extensions.sh
!setup/linux/install-sheldon.sh
!setup/linux/link.sh
!setup/linux/setup.sh
!setup/linux/setup-ja.sh
!setup/windows/get-apps.ps1
!setup/windows/install-apps-from-msstore.ps1
!setup/windows/install-apps-from-winget.ps1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# dotfiles

```shell
curl -fsSL https://raw.githubusercontent.com/kenkenpa198/dotfiles/main/setup/ubuntu/setup.sh | bash
curl -fsSL https://raw.githubusercontent.com/kenkenpa198/dotfiles/main/setup/linux/setup.sh | bash
```

<!-- omit in toc -->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
88 changes: 88 additions & 0 deletions setup/linux/install-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

set -x
set -euo pipefail

# apt でインストールする
function install_with_apt {
# Ubuntu 用パッケージを配列へ追加
packages+=(
"software-properties-common"
)

# パッケージリストの取得・既存パッケージの更新
sudo apt-get update && sudo apt-get upgrade -y

# インストール
for package in "${packages[@]}"
do
sudo apt-get install -y "$package"
done

# Git は PPA からインストールし直す
# https://loumo.jp/archives/23149
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get install -y git

# パッケージのキャッシュを削除
sudo apt-get autoclean -y
}

# pacman でインストールする
function install_with_pacman {
# [pacman - ArchWiki](https://wiki.archlinux.jp/index.php/Pacman)

# Arch 用パッケージを配列へ追加
packages+=(
"pacman-contrib"
)

# パッケージリストの取得・既存パッケージの更新
sudo pacman -Syu

# インストール
sudo pacman -S "${packages[@]}"

# パッケージのキャッシュを削除
paccache -rk1 # 最も新しいバージョン1つだけを保持
paccache -ruk0 # アンインストールされたパッケージのキャッシュを全て削除
}

function main {
# インストールするパッケージの配列を定義
packages=(
"cppcheck"
"curl"
"gcc"
"git"
"neofetch"
"openssh"
"pwgen"
"tree"
"wget"
"zsh"
)

# 利用するパッケージマネージャをディストリビューションごとに切り替える
case `cat /etc/issue` in
Ubuntu*)
: Ubuntu
: Install with apt
install_with_apt
;;
Arch*)
: Arch Linux
: Install with pacman
install_with_pacman
;;
*)
: Unmatched
echo "unmatched distributions"
esac

set +x
echo
echo "Finished: $0"
}

main
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# VS Code の拡張機能リストを1行ずつ変数へ代入して code コマンドでインストールする。

# 実行
# $ bash ~/dotfiles/.setup/Ubuntu/install-vscode-extensions.sh
# $ bash ~/dotfiles/.setup/linux/install-vscode-extensions.sh

# 参考
# https://qiita.com/mottox2/items/581869563ce5f427b5f6
Expand Down
23 changes: 7 additions & 16 deletions setup/ubuntu/link.sh → setup/linux/link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,13 @@ function link_sheldon {

function link_wsl {
# 環境ごとの実行
case ${OSTYPE} in
# Linux
linux* | msys*)
# WSL
if uname -r | grep -i 'microsoft' > /dev/null ; then
# Notes
if [ -d "/mnt/c/Users/$USER" ]; then
mkdir -p "/mnt/c/Users/$USER/works/notes"
ln -sfn "/mnt/c/Users/$USER/works/notes" ~/works/notes
fi
fi
;;
# MacOS
darwin*)
;;
esac
if [[ "$(uname -r)" == *microsoft* ]]; then
# Notes
if [ -d "/mnt/c/Users/$USER" ]; then
mkdir -p "/mnt/c/Users/$USER/works/notes"
ln -sfn "/mnt/c/Users/$USER/works/notes" ~/works/notes
fi
fi
}

function main {
Expand Down
57 changes: 48 additions & 9 deletions setup/ubuntu/setup.sh → setup/linux/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,43 @@ function export_xdg {
export XDG_STATE_HOME="$HOME/.local/state"
}

# git clone dotfiles
function clone_dotfiles {
# pacman の初期化
function init_pacman {
# キーリングの初期化
sudo pacman-key --init
sudo pacman-key --populate
sudo pacman -Syy archlinux-keyring

# ミラーの最適化を自動実行
sudo pacman -g
}

# Git が環境になければインストールする
function check_git {
# https://qiita.com/8ayac/items/b6b6f0a385d08659316b
if ! (type "git" > /dev/null 2>&1); then
sudo apt-get update && \
sudo apt-get install -y git
: Git is not installed
case `cat /etc/issue` in
Ubuntu*)
: Ubuntu
: Install Git with apt
sudo apt-get update && \
sudo apt-get install -y git
;;
Arch*)
: Arch Linux
: Install Git with pacman
sudo pacman -Syu git
;;
*)
: Unmatched
echo "unmatched distributions"
esac
fi
}

# git clone dotfiles
function clone_dotfiles {
DOTFILES_HOME=${HOME}/dotfiles

if [ ! -d "${DOTFILES_HOME}" ]; then
Expand Down Expand Up @@ -75,6 +103,18 @@ function main {
# XDG Base Directory Specification
export_xdg

# Arch の場合のみ pacman を初期化
case `cat /etc/issue` in
Arch*)
: Arch Linux
: Init pacman
init_pacman
;;
esac

# Git が環境になければインストールする
check_git

# git clone dotfiles
clone_dotfiles

Expand All @@ -85,13 +125,12 @@ function main {
backup_origin_files

# アプリケーションのインストール
bash "${HOME}/dotfiles/setup/ubuntu/install-git.sh"
bash "${HOME}/dotfiles/setup/ubuntu/install-apt-packages.sh"
bash "${HOME}/dotfiles/setup/ubuntu/install-sheldon.sh"
bash "${HOME}/dotfiles/setup/ubuntu/install-my-scripts.sh"
bash "${HOME}/dotfiles/setup/linux/install-packages.sh"
bash "${HOME}/dotfiles/setup/linux/install-sheldon.sh"
bash "${HOME}/dotfiles/setup/linux/install-my-scripts.sh"

# シンボリックリンクを作成
bash "${HOME}/dotfiles/setup/ubuntu/link.sh"
bash "${HOME}/dotfiles/setup/linux/link.sh"

# zsh をデフォルトシェルへ設定
sudo chsh "$USER" -s "$(which zsh)"
Expand Down
35 changes: 0 additions & 35 deletions setup/ubuntu/install-apt-packages.sh

This file was deleted.

26 changes: 0 additions & 26 deletions setup/ubuntu/install-git.sh

This file was deleted.

0 comments on commit 12b154e

Please sign in to comment.