Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # System installation script
- from fabric.api import put, run, settings, sudo, task
- from fabric.contrib.files import contains, exists
- @task # Configure wired networking
- def configure_wired_networking():
- sudo('pacman -Sy --needed --noconfirm network-manager-applet \
- networkmanager networkmanager-openvpn networkmanager-pptp \
- networkmanager-vpnc')
- sudo('systemctl enable NetworkManager')
- @task # Configure wireless networking
- def configure_wireless_networking():
- configure_wired_networking()
- sudo('pacman -Sy --needed --noconfirm network-manager-applet \
- networkmanager networkmanager-openvpn wireless_tools wpa_supplicant \
- wpa_actiond dialog')
- @task # Install Intel driver
- def install_video_intel():
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- sudo('pacman -Sy --needed --noconfirm xf86-video-intel \
- lib32-intel-dri lib32-mesa lib32-libgl xorg-server xorg-xinit \
- xorg-server-utils mesa')
- @task # Install nouveau driver
- def install_video_nouveau():
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- sudo('pacman -Sy --needed --noconfirm xf86-video-nouveau \
- lib32-nouveau-dri xorg-server xorg-xinit xorg-server-utils mesa')
- @task # Install nvidia driver
- def install_video_nvidia():
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- sudo('pacman -Sy --needed --noconfirm nvidia lib32-nvidia-libgl \
- xorg-server xorg-xinit xorg-server-utils mesa')
- @task # Install vbox driver
- def install_video_vbox():
- sudo('pacman -Sy --needed --noconfirm virtualbox-guest-utils \
- xorg-server xorg-xinit xorg-server-utils mesa mesa-libgl')
- sudo('touch /etc/modules-load.d/virtualbox.conf')
- sudo('echo vboxguest >> /etc/modules-load.d/virtualbox.conf')
- sudo('echo vboxsf >> /etc/modules-load.d/virtualbox.conf')
- sudo('echo vboxvideo >> /etc/modules-load.d/virtualbox.conf')
- @task # Set hostname for the machine
- def set_hostname():
- sudo('echo "Please enter the hostname:" && read myhostname && \
- hostnamectl set-hostname "$myhostname"')
- @task # Configure date/time synchronization
- def configure_ntp():
- put('ntp.conf', '/etc/ntp.conf', use_sudo=True)
- sudo('chown root:root /etc/ntp.conf')
- sudo('chmod 644 /etc/ntp.conf')
- sudo('pacman -S --needed --noconfirm ntp')
- sudo('systemctl start ntpd')
- sudo('systemctl enable ntpd')
- sudo('timedatectl set-ntp 1')
- @task # Configure repositories
- def configure_repositories():
- if exists('/etc/pacman.d'):
- put('pacman.conf', '/etc/pacman.conf', use_sudo=True)
- sudo('chown root:root /etc/pacman.conf')
- sudo('chmod 644 /etc/pacman.conf')
- sudo('pacman -Syyy')
- sudo('pacman -S --needed --noconfirm yaourt')
- @task # Create local user account
- def create_user():
- if not contains('/etc/group', 'vboxusers'):
- run('groupadd vboxusers')
- if not contains('/etc/group', 'sudo'):
- run('groupadd sudo')
- if contains('/etc/passwd', 'jay'):
- print('The user already exists, so skipping user creation.')
- else:
- run('useradd -m -g users -G wheel,storage,power,vboxusers,sudo -s \
- /bin/bash jay')
- run('passwd jay')
- @task # Install games
- def install_games():
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- if not exists('/home/jay'):
- create_user()
- if not exists('/home/jay/.mame'):
- run('mkdir /home/jay/.mame')
- run('chmod 755 /home/jay/.mame')
- put('mame.ini', '/home/jay/.mame/mame.ini')
- run('chmod 644 /home/jay/.mame/mame.ini')
- run('chown jay:jay -R /home/jay/.mame')
- sudo('pacman -Sy --needed --noconfirm chromium-bsu frozen-bubble \
- mednafen neverball sdlmame supertux supertuxkart steam wesnoth')
- @task # Install GNOME
- def install_gnome():
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- if not exists('/home/jay'):
- create_user()
- sudo('pacman -Sy --needed --noconfirm evince file-roller gnome-control-center \
- gnome-music gnome-power-manager gnome-shell gnome-shell-extensions \
- gnome-terminal gnome-tweak-tool libreoffice-gnome nautilus \
- ttf-liberation ttf-dejavu xdg-user-dirs')
- @task # Install lightdm on the target
- def install_lightdm():
- sudo('pacman -Sy --needed --noconfirm acpid lightdm lightdm-gtk2-greeter')
- if not exists('/etc/lightdm'):
- sudo('mkdir /etc/lightdm')
- put('lightdm.conf', '/etc/lightdm/lightdm.conf', use_sudo=True)
- put('lightdm-gtk-greeter.conf', '/etc/lightdm/lightdm-gtk-greeter.conf', use_sudo=True)
- put('lightdm.png', '/etc/lightdm/lightdm.png', use_sudo=True)
- sudo('systemctl enable lightdm.service')
- sudo('systemctl enable acpid.service')
- sudo('locale-gen')
- @task # Install MATE on the target
- def install_mate():
- sudo('pacman -Sy --needed --noconfirm atril caja mate-backgrounds \
- mate-control-center mate-desktop mate-dialogs \
- mate-icon-theme mate-media-pulseaudio mate-menus \
- mate-notification-daemon mate-panel mate-polkit \
- mate-session-manager mate-settings-daemon-pulseaudio \
- mate-screensvaer-hacks mate-terminal mate-themes mozo pluma')
- @task # Install openbox packages on the target
- def install_openbox():
- if not exists('/home/jay'):
- create_user()
- sudo('pacman -Sy --needed base-devel')
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- if not exists('/usr/bin/yaourt'):
- run('pacman -S --noconfirm yaourt')
- if not exists('/usr/bin/tintwizard'):
- with settings(warn_only=True):
- run('yaourt tintwizard')
- if not exists('/usr/bin/compton'):
- with settings(warn_only=True):
- run('yaourt compton')
- sudo('pacman -Sy --needed --noconfirm acpid cantarell-fonts \
- clipit dmenu gksu gmrun gnome-keyring gnome-themes-standard gsimplecal \
- gtk-engine-murrine gtk-engine-unico lxappearance mousepad nitrogen \
- obconf oblogout obmenu openbox pcmanfm plank scrot tint2 tilda \
- volumeicon xarchiver xscreensaver')
- put('oblogout.conf', '/etc/oblogout.conf', use_sudo=True)
- @task # Install packages
- def install_packages():
- sudo('pacman -Sy --needed base-devel')
- if not contains('/etc/pacman.conf', 'archlinuxfr'):
- configure_repositories()
- if not exists('/home/jay'):
- create_user()
- if not exists('/usr/bin/yaourt'):
- sudo('pacman -Sy --noconfirm yaourt')
- if not exists('/usr/bin/google-chrome-stable'):
- with settings(warn_only=True):
- run('yaourt google-chrome')
- if not exists('/usr/bin/urxvt'):
- with settings(warn_only=True):
- run('yaourt rxvt-unicode-pixbuf')
- sudo('pacman -Sy --needed --noconfirm alsa-utils asunder banshee \
- brasero cmus codeblocks colordiff conky dosfstools easytag eclipse \
- exfat-utils fabric filezilla fish flake8 freerdp fuse-exfat \
- galculator geany geany-plugins gimp git gparted gst-libav \
- gst-plugins-bad gst-plugins-base gst-plugins-good gst-plugins-ugly \
- gvfs gvfs-smb gtk-recordmydesktop guake htop hunspell-en hyphen-en \
- iotop lame libreoffice-writer libreoffice-calc linux-lts \
- linux-lts-headers libreoffice-common libreoffice-en-US \
- libreoffice-impress libtheora libvorbis lm_sensors midori mosh mpv \
- ncdu net-tools nfs-utils ntfs-3g openssh pavucontrol p7zip pep8-python2 \
- pep8-python3 plank python-pip remmina roxterm screen smbclient sshfs \
- stalonetray synapse terminus-font terminator the_silver_searcher tmux \
- transmission-gtk \ttf-liberation ttf-dejavu unrar viewnior vim-nerdtree \
- vim-python3 vim-colorsamplerpack vlc vorbis-tools xchat \
- xcursor-vanilla-dmz xsel xterm xvidcore zip')
- put('syncthing.service', '/etc/systemd/system/syncthing.service', use_sudo=True)
- sudo('chown root:root /etc/systemd/system/syncthing.service')
- sudo('chmod +x /etc/systemd/system/syncthing.service')
- sudo('systemctl enable syncthing.service')
- if not exists('/home/jay/.local/share/applications'):
- run('mkdir -p /home/jay/.local/share/applications')
- run('chmod 755 -R /home/jay/.local')
- if not exists('/home/jay/.local/share/applications/firefox.desktop'):
- put('firefox.desktop', '\
- /home/jay/.local/share/applications/firefox.desktop')
- if not exists('/home/jay/.local/share/applications/\
- thunderbird.desktop'):
- put('thunderbird.desktop', '\
- /home/jay/.local/share/applications/thunderbird.desktop')
- @task # Install sudo
- def install_sudo():
- sudo('pacman -S --needed --noconfirm sudo')
- if not contains('/etc/group', 'sudo'):
- sudo('groupadd sudo')
- if not exists('/home jay'):
- create_user()
- run('usermod -aG sudo jay')
- @task # Configure virtualbox host
- def setup_virtualbox_host():
- if not exists('/home/jay'):
- create_user()
- sudo('pacman -S --needed --noconfirm linux-headers virtualbox \
- virtualbox-host-modules virtualbox-host-modules-lts virtualbox-guest-iso')
- sudo('usermod -aG vboxusers jay')
- sudo('touch /etc/modules-load.d/virtualbox.conf')
- sudo("echo 'vboxdrv' > /etc/modules-load.d/virtualbox.conf")
- sudo("echo 'vboxnetadp' >> /etc/modules-load.d/virtualbox.conf")
- sudo("echo 'vboxnetflt' >> /etc/modules-load.d/virtualbox.conf")
Advertisement
Add Comment
Please, Sign In to add comment