~tardypad/arch-system

ref: 34a8268a55999f367e39dfdb71b10a2c29dc6287 arch-system/setup/setup-system -rwxr-xr-x 1.7 KiB
34a8268a — Damien Tardy-Panis Update packages version in README 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
# commands used:
# - pacman

init_variables() {
  COMMAND=${0##*/}
}

show_usage() {
  cat <<- EOF
	usage: ${COMMAND} [<options>]

	Setup a new system after basic Arch installation

	Needs to be run as a root user

	Options:
	  -h    show this message only
	EOF
}

parse_command_line() {
  while getopts h OPT; do
    case "${OPT}" in
      h) show_usage; exit 0 ;;
      ?) exit_error ;;
    esac
  done

  shift $(( OPTIND - 1 ))
}

exit_error() {
  [ -z "$1" ] || echo "${COMMAND}: $1"
  echo "Try '${COMMAND} -h' for more information."
  exit 1
} >&2

check_root_user() {
  [ "$( id -u )" -ne 0 ] && exit_error 'The script must be run as root'
}

update_current_packages() {
  pacman -Syu --noconfirm
}

setup_repositories() {
  echo 'Enter pkgs.tardypad.me HTTP credentials'
  printf 'username: '; read -r USERNAME
  printf 'password: '; read -r PASSWORD

  cat >> /etc/pacman.conf <<- EOF
	[tardypad]
	SigLevel = Optional TrustAll
	Server = https://${USERNAME}:${PASSWORD}@pkgs.tardypad.me/tardypad

	[aur]
	SigLevel = Optional TrustAll
	Server = https://${USERNAME}:${PASSWORD}@pkgs.tardypad.me/aur
	EOF
}

install_packages() {
  pacman -S --overwrite '*' system-config
}

setup_users() {
  useradd -mU -s /usr/bin/zsh -G uucp,video,wheel,input damien
  passwd damien

  chsh -s /usr/bin/zsh root

  mkdir -p /home/damien/Contacts
  mkdir -p /home/damien/Desktop
  mkdir -p /home/damien/Downloads
  mkdir -p /home/damien/Documents
  mkdir -p /home/damien/Music
  mkdir -p /home/damien/Notes
  mkdir -p /home/damien/Pictures
  mkdir -p /home/damien/Projects
  mkdir -p /home/damien/Videos

  chown -R damien:damien /home/damien
}

init_variables
parse_command_line "$@"

check_root_user

setup_repositories
update_current_packages
install_packages
setup_users