Skip to content

Instantly share code, notes, and snippets.

@mezcel
Last active May 18, 2019 08:00
Show Gist options
  • Select an option

  • Save mezcel/8a6d81a14b16fd5523131a60f2431d9f to your computer and use it in GitHub Desktop.

Select an option

Save mezcel/8a6d81a14b16fd5523131a60f2431d9f to your computer and use it in GitHub Desktop.
My default archlive builder

Archiso

Make a basic custom Arch Distro from a default Arch ISO.

  • Copy this repo into the bootable usb or mount it durring the Arch live usb session.

  • ./1.0-boot_install.sh Offline Arch installation

  • ./1.0.1* will populate your OS with software packages from the pacman_pkglist.txt and an openbox destop environment.

    • internet required
  • ./999* will generate a new arch iso based on the system you wany

You will still need your own .config dir and your own mirrorlist file.

  • The .config dir will be automatically generated in your ~/ dir as you customize your linux sytem by adding software packages.

  • You can make a mirrorlist specific to your region using the mirrorlist generator: link

  • put the mirrorlist into this dir before running ./1.0.1*

#!/bin/sh
## This script assumes you have https://github.com/mezcel/arch-openbox.git in your home dir
## Arch Linux Boot from Iso
## Really fast install via Usb, but about 30min via slow internet
## terminal beautification
function decorativeColors() {
## ${Black}
## https://en.wikipedia.org/wiki/ANSI_escape_code
## https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
## Usage example: echo "abcd $MODE_BEGIN_UNDERLINE edf $MODE_EXIT_UNDERLINE $FG_RED hijk $STYLES_OFF
## Forground Color using ANSI escape
FG_BLACK=$(tput setaf 0)
FG_RED=$(tput setaf 1)
FG_GREEN=$(tput setaf 2)
FG_YELLOW=$(tput setaf 3)
FG_BLUE=$(tput setaf 4)
FG_MAGENTA=$(tput setaf 5)
FG_CYAN=$(tput setaf 6)
FG_WHITE=$(tput setaf 7)
FG_NoColor=$(tput sgr0)
## Background Color using ANSI escape
BG_BLACK=$(tput setab 0)
BG_RED=$(tput setab 1)
BG_GREEN=$(tput setab 2)
BG_YELLOW=$(tput setab 3)
BG_BLUE=$(tput setab 4)
BG_MAGENTA=$(tput setab 5)
BG_CYAN=$(tput setab 6)
BG_WHITE=$(tput setab 7)
BG_NoColor=$(tput sgr0)
## set mode using ANSI escape
MODE_BOLD=$(tput bold)
MODE_DIM=$(tput dim)
MODE_BEGIN_UNDERLINE=$(tput smul)
MODE_EXIT_UNDERLINE=$(tput rmul)
MODE_REVERSE=$(tput rev)
MODE_ENTER_STANDOUT=$(tput smso)
MODE_EXIT_STANDOUT=$(tput rmso)
# clear styles using ANSI escape
STYLES_OFF=$(tput sgr0)
}
function format_HDD() {
# del existing partitions
(echo d; echo ""; echo w;) | fdisk /dev/sda
sleep 1s
(echo d; echo ""; echo w;) | fdisk /dev/sda
sleep 1s
(echo d; echo ""; echo w;) | fdisk /dev/sda
sleep 1s
# make new partitions
(echo o; echo n; echo p; echo 2; echo ""; echo +1G; echo w; echo "";) | fdisk /dev/sda
sleep 1s
(echo n; echo p; echo 1; echo ""; echo ""; echo w; echo "";) | fdisk /dev/sda
sleep 1s
(echo y;) | mkfs.ext4 /dev/sda1
sleep 1s
mkswap /dev/sda2
sleep 1s
swapon /dev/sda2
sleep 1s
# Mount
# mkdir /mnt
mount /dev/sda1 /mnt
sleep 1s
}
function format_SSD_HDD() {
## del any existing partitions
(echo d; echo 1; echo ""; echo w;) | fdisk /dev/mmcblk0
sleep 1s
(echo d; echo 2; echo ""; echo w;) | fdisk /dev/mmcblk0
sleep 1s
(echo d; echo 3; echo ""; echo w;) | fdisk /dev/mmcblk0
sleep 1s
(echo d; echo 4; echo ""; echo w;) | fdisk /dev/mmcblk0
sleep 1s
(echo d; echo ""; echo w;) | fdisk /dev/mmcblk0
sleep 1s
## make new partitions
## +256M UEFI Boot partition is a guess, Win10 likes 4K-25M, yet 256M-500M is recomended by the ArchWiki, Ubuntu doesent even care
(echo o; echo n; echo p; echo 1; echo ""; echo +256M; echo w; echo "";) | fdisk /dev/mmcblk0
sleep 1s
## I put in swap just as a curtesy
(echo n; echo p; echo 3; echo ""; echo +1G; echo w; echo "";) | fdisk /dev/mmcblk0
sleep 1s
(echo n; echo p; echo 2; echo ""; echo ""; echo w; echo "";) | fdisk /dev/mmcblk0
sleep 1s
## Format for uefi boot system
(echo y;) | mkfs.fat -F32 /dev/mmcblk0p1
sleep 1s
(echo y;) | mkfs.ext4 /dev/mmcblk0p2
sleep 1s
## extra swap just to have it
mkswap /dev/mmcblk0p3
sleep 1s
swapon /dev/mmcblk0p3
sleep 1s
## Mount
mount /dev/mmcblk0p2 /mnt
sleep 1s
}
function packstrap_from_iso() {
## my regional mirrorlist for pacman
mirrorlist_backup="/etc/pacman.d/mirrorlist"
if [ -f "$mirrorlist_backup" ]
then mv "$mirrorlist_backup" "$mirrorlist_backup.backup.$(date +%H%M%S)"
fi
sleep 1s
# cp ~/arch-openbox/mirrorlist /etc/pacman.d/mirrorlist
currentDirPath=$(dirname $0)
cp $currentDirPath/mirrorlist /etc/pacman.d/mirrorlist
sleep 1s
## Customize my Skel
## copy my current home to skel
# cp -r ~/* /etc/skel
# cp -r ~/.* /etc/skel
## Usb merge resource from usb
time cp -ax / /mnt
sleep 2s
cp -vaT /run/archiso/bootmnt/arch/boot/x86_64/vmlinuz /mnt/boot/vmlinuz-linux
sleep 2s
# pacman -Sy
## Install the base packages
# pacstrap /mnt base base-devel
## Generate an fstab
genfstab -p /mnt >> /mnt/etc/fstab
sleep 1s
}
function chroot_localization() {
# Chroot into your newly installed system
# remove a lot of things that were imported from usb iso
(
# Localization
echo timedatectl set-ntp true;
echo ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime;
echo "echo en_US.UTF-8 UTF-8 >> /etc/locale.gen";
echo locale-gen;
echo hwclock --systohc;
echo "echo LANG=en_US.UTF-8 >> /etc/locale.conf";
# Restore the configuration of journald
echo sed -i 's/Storage=volatile/#Storage=auto/' /etc/systemd/journald.conf;
# Remove special udev rule
echo rm /etc/udev/rules.d//81-dhcpcd.rules;
# Disable and remove the services created by archiso
echo systemctl disable pacman-init.service choose-mirror.service;
echo rm /etc/systemd/system/choose-mirror.service;
echo rm /etc/systemd/system/pacman-init.service;
echo rm /etc/systemd/system/etc-pacman.d-gnupg.mount;
echo rm -rf /etc/systemd/system/[email protected];
echo rm /etc/systemd/scripts/choose-mirror;
# Remove special scripts of the Live environment
echo rm /etc/systemd/system/[email protected]/autologin.conf;
echo rm /root/.automated_script.sh;
echo rm /root/.zlogin;
echo rm /etc/mkinitcpio-archiso.conf;
echo rm -r /etc/initcpio/;
# Import archlinux keys
echo pacman-key --init;
echo pacman-key --populate archlinux;
echo sleep 1s;
# Initramfs
echo mkinitcpio -p linux;
echo sleep 4s;
echo exit;
) | arch-chroot /mnt /bin/bash
}
function chroot_biosGrub() {
## GRUB Stuff
## Install Grub Bootloader
(
## Install Grub Bootloader
echo pacman -S --needed grub;
echo grub-install --target=i386-pc --recheck --force /dev/sda;
echo sleep 2s;
echo cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo;
echo grub-mkconfig -o /boot/grub/grub.cfg;
echo sleep 2s;
echo exit;
) | arch-chroot /mnt /bin/bash
}
function chroot_uefiGrub() {
# wifi-menu
# sleep 3s # Waits 3 seconds.
# pacman -Sy
## GRUB Stuff
## im gona want to enable internet to dl grub and efibootmgr
## maybe in the near future I wont need to mess with even this step
(
## Install Grub Bootloader
echo pacman -S --noconfirm grub;
echo pacman -S --noconfirm efibootmgr;
echo mkdir /boot/efi;
echo mount /dev/mmcblk0p1 /boot/efi;
echo sleep 4s;
echo grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi;
echo sleep 2s;
echo grub-mkconfig -o /boot/grub/grub.cfg;
echo sleep 2s;
## tricky stuff to make sure it always boot
echo mkdir /boot/efi/EFI/BOOT;
echo cp /boot/efi/EFI/GRUB/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI;
echo "echo bcf boot add 1 fs0:\\\EFI\GRUB\\\grubx64.efi \\\"My GRUB bootloader\\\" >> /boot/efi/startup.nsh";
echo "echo exit >> /boot/efi/startup.nsh";
echo sleep 4s;
echo exit;
) | arch-chroot /mnt /bin/bash
}
function biosgrub() {
timedatectl set-ntp true
## Partition Destination Drive
echo "$FG_YELLOW
About to prepare destination drive...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
format_HDD
## Packstrap and cutomization
echo "$FG_YELLOW
About to prepare packstrap...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
packstrap_from_iso
echo "$FG_YELLOW
About to prepare chroot customizations...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
chroot_localization
## GRUB STUFF
echo "$FG_YELLOW
About to prepare grub...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
chroot_biosGrub
}
function uefigrub() {
timedatectl set-ntp true
## Partition Destination Drive
echo "$FG_YELLOW
About to prepare destination drive...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
format_SSD_HDD
## Packstrap and cutomization
echo "$FG_YELLOW
About to prepare packstrap
$FG_NoColor"
sleep 3s # Waits 3 seconds.
packstrap_from_iso
echo "$FG_YELLOW
About to prepare chroot customizations...
$FG_NoColor"
sleep 3s # Waits 3 seconds.
chroot_localization
## GRUB STUFF
echo "$FG_YELLOW
About to prepare grub
$FG_NoColor"
sleep 3s # Waits 3 seconds.
chroot_uefiGrub
}
function closeOut() {
## Done
umount -R /mnt
sleep 2s # Waits 2 seconds.
echo "$FG_YELLOW
Just a 2 sec delay to allow unmounting to settle...
"
shutdown now
}
function main_menu() {
dialogBackTitle="Install from iso"
dialogTitle="Bootloader Options"
selectedMenuItem=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--cancel-label "Back" \
--menu "Select you boot firmware type:" 10 40 2 \
"1" "Grub on BIOS Bootloader" \
"2" "Grub on UEFI Bootloader") || return
if [[ $selectedMenuItem = 1 ]]; then
biosgrub
fi
if [[ $selectedMenuItem = 2 ]]; then
uefigrub
fi
clear
}
## Start the DIY installer
decorativeColors
main_menu
## Done
sleep 4s
closeOut
#!/bin/sh
function packageManagerPacman {
## Pacman in silen mode
sudo pacman -Sy
sudo pacman -Syyu
declare -a missingPackageArr=()
count=0
## Check if required software is allready installed
## Add missing packages to an array of missing packages
currentDirPath=$(dirname $0)
while read linePackage
do
count=$(( $count + 1 ))
statusMsg=$(pacman -Qs $linePackage)
isPackageMissing=$?
if [ $isPackageMissing -eq 1 ]; then
sudo pacman -Sy --noconfirm --needed $linePackage
sleep 1s
fi
done < $currentDirPath/pacman_pkglist.txt
}
function userConfigs {
mkdir ~/Downloads ~/Documents ~/github
mkdir ~/github/mezcel
touch ~/.nanorc
touch ~/.xinitrc
echo "include /usr/share/nano/sh.nanorc" >> ~/.nanorc
echo "set smooth" >> ~/.nanorc
echo "set autoindent" >> ~/.nanorc
echo "set tabsize 4" >> ~/.nanorc
echo "set linenumbers" >> ~/.nanorc
## My windows manager of choice
echo "#!/bin/sh" >> ~/.xinitrc
echo "exec openbox-session" >> ~/.xinitrc
cp -rf .config ~/
}
function myGithubDir {
cd ~/github/mezcel
git clone https://github.com/mezcel/printf-time.git
git clone https://github.com/mezcel/jq-tput-terminal.git
git clone https://github.com/mezcel/carousel-score.git
git clone https://github.com/mezcel/electron-container.git
git clone https://github.com/mezcel/Toggle-Tag.git
git clone https://github.com/mezcel/googlemaps-api-helloworld.git
}
function geanyThemes {
cd ~/
sudo pacman -Sy --needed geany geany-plugins
mkdir ~/github/codebrainz
sleep 3s
cd ~/github/codebrainz
sleep 3s
git clone https://github.com/codebrainz/geany-themes.git
sleep 3s
cd ~/github/codebrainz/geany-themes
sleep 3s
source install.sh
}
function run {
packageManagerPacman
userConfigs
myGithubDir
geanyThemes
cd ~/
}
sudo wifi-menu
echo "\nAprox 10s delay ... \n"
sleep 10s
run
echo "\n\nDone\n\n"
#!/bin/sh
# https://wiki.archlinux.org/index.php/archiso#Setup
# run this script in sudo
pacman -S archiso
## choose: releng or baseline
## releng is your arch ## baseline is just arch
cp -r /usr/share/archiso/configs/releng/ ~/archlive
## list of all packages on my system
pacman -Qqe > ~/archlive/packages.x86_64
## Make my custom iso
mkdir ~/archlive/out/
#############
### This is custom for my partiular live usb copy
## prepare files for skel
mkdir ~/archlive/airootfs/etc/skel
sleep 2s
cp ~/.nanorc ~/archlive/airootfs/etc/skel
cp ~/.xinitrc ~/archlive/airootfs/etc/skel
cp -rf ~/.config ~/archlive/airootfs/etc/skel
# currentDirPath=$(dirname $0)
# cp mirrorlist $currentDirPath/etc/pacman.d/mirrorlist
## build when i have skell the way I want it
cd ~/archlive
./build.sh -v
#!/bin/bash
## Openbox Xfce4 i3
## Networking and dev utils
sudo pacman -S --noconfirm --needed base
sudo pacman -S --noconfirm --needed base-devel
sudo pacman -S --noconfirm --needed xorg
sudo pacman -S --noconfirm --needed xorg-twm
sudo pacman -S --noconfirm --needed xorg-xinit
sudo pacman -S --noconfirm --needed xorg-server
sudo pacman -S --noconfirm --needed xorg-server-utils
sudo pacman -S --noconfirm --needed xorg-apps
sudo pacman -S --noconfirm --needed xorg-xrandr
sudo pacman -S --noconfirm --needed gcc cmake extra-cmake-modules
sudo pacman -S --noconfirm --needed python python-pip python-setuptools
sudo pacman -S --noconfirm --needed python2 python2-pip python2-setuptools python2-xdg
sudo pacman -S --noconfirm --needed java-runtime-common jdk-openjdk jre-openjdk
sudo pacman -S --noconfirm --needed nodejs npm
sudo pacman -S --noconfirm --needed mesa lib32-mesa xf86-video-mesa
sudo pacman -S --noconfirm --needed xf86-video-amdgpu xf86-video-ati xf86-video-intel
sudo pacman -S --noconfirm --needed arandr
sudo pacman -S --noconfirm --needed alsa alsa-utils alsa-firmware
sudo pacman -S --noconfirm --needed pulseaudio pulseaudio-alsa
sudo pacman -S --noconfirm --needed pavucontrol vorbis-tools
sudo pacman -S --noconfirm --needed git wget
sudo pacman -S --noconfirm --needed net-tools networkmanager
sudo pacman -S --noconfirm --needed openssh macchanger
sudo pacman -S --noconfirm --needed hostapd iptables
sudo pacman -S --noconfirm --needed nftables create_ap
sudo pacman -S --noconfirm --needed openbox xfce4 i3
echo "exec i3" > ~/.xinitrc
sudo pacman -S --noconfirm --needed mousepad geany geany-plugins
sudo pacman -S --noconfirm --needed adobe-source-code-pro-fonts adobe-source-sans-pro-fonts ttf-ubuntu-font-family ttf-inconsolata
sudo pacman -S --noconfirm --needed xterm obconf openbox-themes xfce4-goodies i3-wm
sudo pacman -S --noconfirm --needed thunar-archive-plugin thunar-media-tags-plugin thunar-volman
sudo pacman -S --noconfirm --needed file-roller xfwm4 xarchiver
sudo pacman -S --noconfirm --needed feh dmenu mc tree p7zip
sudo pacman -S --noconfirm --needed libreoffice-fresh hunspell hunspell-en_US
sudo pacman -S --noconfirm --needed elinks firefox
sudo pacman -S --noconfirm --needed mplayer vlc
echo "-------------------------------"
echo "# git config --global user.name"
read -p "Set github user name: " githubusername
echo ""
echo "# git config --global user.email"
read -p "Set github user email: " githubuseremail
echo "---"
git config --global user.name $githubusername
git config --global user.email $githubuseremail
echo "Done."
#!/bin/sh
function packageManagerPacman {
## Pacman in silen mode
sudo pacman -Sy
# sudo pacman -Syyu
declare -a missingPackageArr=()
count=0
## Check if required software is allready installed
## Add missing packages to an array of missing packages
currentDirPath=$(dirname $0)
while read linePackage
do
count=$(( $count + 1 ))
statusMsg=$(pacman -Qs $linePackage)
isPackageMissing=$?
if [ $isPackageMissing -eq 1 ]; then
sudo pacman -Sy --noconfirm --needed $linePackage
sleep 1s
fi
done < $currentDirPath/pacman_pkglist.txt
}
packageManagerPacman
##
## Arch Linux repository mirrorlist
## Generated on 2018-11-26
## https://www.archlinux.org/mirrorlist/
## /etc/pacman.d/mirrorlist
##
## United States
Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch
Server = http://mirror.siena.edu/archlinux/$repo/os/$arch
Server = https://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch
Server = https://archlinux.surlyjake.com/archlinux/$repo/os/$arch
Server = http://mirror.dc02.hackingand.coffee/arch/$repo/os/$arch
Server = http://mirrors.sonic.net/archlinux/$repo/os/$arch
Server = http://mirrors.xtom.com/archlinux/$repo/os/$arch
Server = http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch
Server = http://distro.ibiblio.org/archlinux/$repo/os/$arch
Server = http://mirrors.sorengard.com/archlinux/$repo/os/$arch
Server = https://mirror.lty.me/archlinux/$repo/os/$arch
Server = http://arch.mirror.square-r00t.net/$repo/os/$arch
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch
Server = http://mirror.lty.me/archlinux/$repo/os/$arch
Server = http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
Server = https://mirror.hackingand.coffee/arch/$repo/os/$arch
Server = http://repo.ialab.dsu.edu/archlinux/$repo/os/$arch
Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch
Server = https://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
Server = https://mirrors.rutgers.edu/archlinux/$repo/os/$arch
Server = http://arch.mirror.constant.com/$repo/os/$arch
Server = http://mirror.stephen304.com/archlinux/$repo/os/$arch
Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://arch.mirrors.pair.com/$repo/os/$arch
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
Server = https://mirrors.sonic.net/archlinux/$repo/os/$arch
Server = https://mirrors.xtom.com/archlinux/$repo/os/$arch
Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://ca.us.mirror.archlinux-br.org/$repo/os/$arch
Server = https://arch.mirror.square-r00t.net/$repo/os/$arch
Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch
Server = http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch
Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch
Server = http://mirror.hackingand.coffee/arch/$repo/os/$arch
Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch
Server = http://repo.miserver.it.umich.edu/archlinux/$repo/os/$arch
Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch
Server = https://mirror.grig.io/archlinux/$repo/os/$arch
Server = https://mirrors.rit.edu/archlinux/$repo/os/$arch
Server = http://mirror.grig.io/archlinux/$repo/os/$arch
Server = https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://il.us.mirror.archlinux-br.org/$repo/os/$arch
Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch
Server = https://mirror.dc02.hackingand.coffee/arch/$repo/os/$arch
Server = https://mirrors.sorengard.com/archlinux/$repo/os/$arch
Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch
Server = https://mirror.kaminski.io/archlinux/$repo/os/$arch
Server = http://mirror.epiphyte.network/archlinux/$repo/os/$arch
Server = http://mirror.as65535.net/archlinux/$repo/os/$arch
Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
Server = https://mirror.epiphyte.network/archlinux/$repo/os/$arch
Server = http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://arch.mirror.constant.com/$repo/os/$arch
Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch
Server = https://mirror.stephen304.com/archlinux/$repo/os/$arch
##
## Arch Linux repository mirrorlist (Alternates)
## Filtered by mirror score from mirror status page
## Generated on 2018-11-28
##
## Canada
Server = https://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch
## United Kingdom
Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch
## Japan
Server = https://mirrors.cat.net/archlinux/$repo/os/$arch
## Japan
Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
## Canada
Server = http://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch
## Canada
Server = https://muug.ca/mirror/archlinux/$repo/os/$arch
## United Kingdom
Server = https://mirrors.ukfast.co.uk/sites/archlinux.org/$repo/os/$arch
## Canada
Server = http://archlinux.mirror.colo-serv.net/$repo/os/$arch
## United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## United Kingdom
Server = https://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
## Japan
Server = https://jpn.mirror.pkgbuild.com/$repo/os/$arch
## Mexico
Server = https://mex.mirror.pkgbuild.com/$repo/os/$arch
## Canada
Server = http://mirror.cedille.club/archlinux/$repo/os/$arch
## Japan
Server = https://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
## Canada
Server = https://mirror.sergal.org/archlinux/$repo/os/$arch
## Singapore
Server = http://mirror.nus.edu.sg/archlinux/$repo/os/$arch
## Singapore
Server = https://mirror.0x.sg/archlinux/$repo/os/$arch
## United Kingdom
Server = https://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
## United Kingdom
Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
## Japan
Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
## United Kingdom
Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch
## Japan
Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch
## Canada
Server = http://mirror.sergal.org/archlinux/$repo/os/$arch
## Canada
Server = http://muug.ca/mirror/archlinux/$repo/os/$arch
## Singapore
Server = https://sgp.mirror.pkgbuild.com/$repo/os/$arch
## Canada
Server = http://archlinux.mirror.rafal.ca/$repo/os/$arch
## Singapore
Server = http://mirror.0x.sg/archlinux/$repo/os/$arch
## United Kingdom
Server = http://mirrors.ukfast.co.uk/sites/archlinux.org/$repo/os/$arch
## ~/.nanorc
include /usr/share/nano/sh.nanorc
set smooth
set autoindent
set tabsize 4
set linenumbers
include /usr/share/nano/*
#!/bin/sh
## A Dialog UI for nmcli
## terminal beautification
function decorativeColors() {
## ${Black}
## https://en.wikipedia.org/wiki/ANSI_escape_code
## https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/
## Usage example: echo "abcd $MODE_BEGIN_UNDERLINE edf $MODE_EXIT_UNDERLINE $FG_RED hijk $STYLES_OFF
## Forground Color using ANSI escape
FG_BLACK=$(tput setaf 0)
FG_RED=$(tput setaf 1)
FG_GREEN=$(tput setaf 2)
FG_YELLOW=$(tput setaf 3)
FG_BLUE=$(tput setaf 4)
FG_MAGENTA=$(tput setaf 5)
FG_CYAN=$(tput setaf 6)
FG_WHITE=$(tput setaf 7)
FG_NoColor=$(tput sgr0)
## Background Color using ANSI escape
BG_BLACK=$(tput setab 0)
BG_RED=$(tput setab 1)
BG_GREEN=$(tput setab 2)
BG_YELLOW=$(tput setab 3)
BG_BLUE=$(tput setab 4)
BG_MAGENTA=$(tput setab 5)
BG_CYAN=$(tput setab 6)
BG_WHITE=$(tput setab 7)
BG_NoColor=$(tput sgr0)
## set mode using ANSI escape
MODE_BOLD=$(tput bold)
MODE_DIM=$(tput dim)
MODE_BEGIN_UNDERLINE=$(tput smul)
MODE_EXIT_UNDERLINE=$(tput rmul)
MODE_REVERSE=$(tput rev)
MODE_ENTER_STANDOUT=$(tput smso)
MODE_EXIT_STANDOUT=$(tput rmso)
# clear styles using ANSI escape
STYLES_OFF=$(tput sgr0)
}
function nmcli_wifi_connect() {
nmcli networking on
dialogBackTitle="nmcli-menu"
dialogTitle="Connect to Wifi Access Point"
nmcli device wifi rescan
declare -a nmcliArray
nmcliArray=($(nmcli -c no -m tabular -f SSID dev wifi))
declare -a menuArray
for ((i=1; i<${#nmcliArray[@]}; i+=1)); do
rawVal=${nmcliArray[$i]}
cleanedVal=${rawVal// /}
menuArray+=("$(($i))" "$cleanedVal" )
done
selectedWifi=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--menu "wifi list" \
12 50 ${#nmcliArray[@]} \
${menuArray[@]}
) || return
ssidName=$(echo "${nmcliArray[$(($selectedWifi))]}" | xargs)
wifiPassword=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--insecure --passwordbox "Wifi Password:" 10 50 "yourpassword" ) || return
myTerminalAlias=$(whoami)@$(hostname)
dialog \
--backtitle "Network Connection" \
--title "Attemting to log in" \
--infobox "Process running:\n\n$myTerminalAlias:\nnmcli device wifi connect $ssidName password \$wifiPassword\n\nPlease just wait... its going to happen..." 11 80
# nmcli networking on
# nmcli device wifi connect $ssidName password $wifiPassword
nmcli device wifi connect $ssidName password $wifiPassword
clear
echo "
+5 sec delay...
Prevents the script from going too fast to connect.
"
sleep 5s
nmcli connection up $ssidName
sleep 5s
netctl start $ssidName
}
function new_access_point() {
editConnection=$(dialog 2>&1 >/dev/tty \
--backtitle "WI-FI, Hotspot, Internet Connection Settings" \
--title "CONNECTION ACCESS POINT SETUP" \
--form "\nConnection Settings:\n review your: ifconfig; nmcli device" \
0 0 0 \
"SSID:" 1 1 "A_Ssid_Connection_Name" 1 30 40 0 \
"Mode: (wifi/ethernet)" 2 1 "wifi" 2 30 40 0 \
"Device HWaddr ifname:" 3 1 "wlp1s0" 3 30 40 0 \
"Automatically connect:" 4 1 "yes" 4 30 40 0 \
"IPv4 Method: (shared/manual)" 5 1 "shared" 5 30 40 0 \
"Password:" 6 1 "password1234" 6 30 40 0 \
"ipv4.addresses: * ethernet *" 7 1 "192.168.0.100/24" 7 30 40 0 \
"ipv4.gateway: * ethernet *" 8 1 "192.168.0.1" 8 30 40 0 )
selectedSubMenuItem1=($editConnection)
myconshow=($(nmcli device))
if [[ " ${myconshow[@]} " =~ "${selectedSubMenuItem1[0]}" ]]; then
dialog \
--infobox "The SSID \"${selectedSubMenuItem1[0]}\", which you defined, allready exists.\n\nOnly make a NEW connection that is NEW to your system." 10 40
#sleep 3
read -t 3
else
sleep 3
perform_connection_setup
fi
}
function perform_connection_setup() {
## Template
## nmcli con add type "wifi" ifname "wlp1s0" con-name "mylocalSSIDname" autoconnect yes ssid "theRouterSSIDname"
## nmcli con modify "mylocalSSIDname" 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method "shared"
## nmcli con modify "mylocalSSIDname" wifi-sec.key-mgmt wpa-psk
## nmcli con modify "mylocalSSIDname" wifi-sec.psk "mypassword"
## nmcli con modify "mylocalSSIDname" ipv4.addresses "192.168.0.22/16"
## nmcli con modify "mylocalSSIDname" ipv4.gateway "192.168.0.1"
##
## OR
## cp /etc/netctl/examples/wireless-wpa /etc/netctl/"mylocalSSIDname"
## echo "Interface=wlp1s0" >> /etc/netctl/"mylocalSSIDname"
## echo "Connection=wireless" >> /etc/netctl/"mylocalSSIDname"
## echo "Security=wpa" >> /etc/netctl/"mylocalSSIDname"
## echo "ESSID=routerssid" >> /etc/netctl/"mylocalSSIDname"
## echo "IP=dhcp" >> /etc/netctl/"mylocalSSIDname"
## echo "Key=mypassword" >> /etc/netctl/"mylocalSSIDname"
## involves password and radio
if [[ "${selectedSubMenuItem1[1]}" == "wifi" ]]; then
# Mode is wifi
nmcli con add type ${selectedSubMenuItem1[1]} ifname ${selectedSubMenuItem1[2]} con-name ${selectedSubMenuItem1[0]} autoconnect ${selectedSubMenuItem1[3]} ssid ${selectedSubMenuItem1[0]}
nmcli con modify ${selectedSubMenuItem1[0]} 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method ${selectedSubMenuItem1[4]}
nmcli con modify ${selectedSubMenuItem1[0]} wifi-sec.key-mgmt wpa-psk
nmcli con modify ${selectedSubMenuItem1[0]} wifi-sec.psk ${selectedSubMenuItem1[5]}
nmcli radio on
fi
## involves ip's
if [[ "${selectedSubMenuItem1[1]}" == "ethernet" ]]; then
# Mode is ethernet
nmcli con add type ${selectedSubMenuItem1[1]} ifname ${selectedSubMenuItem1[2]} con-name ${selectedSubMenuItem1[0]} autoconnect ${selectedSubMenuItem1[3]}
nmcli con modify ${selectedSubMenuItem1[0]} ipv4.method ${selectedSubMenuItem1[4]}
nmcli con modify ${selectedSubMenuItem1[0]} ipv4.addresses ${selectedSubMenuItem1[6]}
nmcli con modify ${selectedSubMenuItem1[0]} ipv4.gateway ${selectedSubMenuItem1[7]}
fi
nmcli con up ${selectedSubMenuItem1[0]}
sleep 5s
nmcli networking on
sleep 5s
netctl start ${selectedSubMenuItem1[0]}
}
function sshd_service() {
dialogBackTitle="SSH Server"
dialogTitle="SSHD Options"
selectedSSHMenu=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--cancel-label "Back" \
--menu "SSHD Options:" 0 0 0 \
"1" "systemctl start sshd"\
"2" "systemctl enable sshd"\
"3" "systemctl stop sshd"\
"4" "systemctl restart sshd" ) || return
if [[ $selectedSSHMenu == 1 ]]; then
clear
systemctl start sshd
fi
if [[ $selectedSSHMenu == 2 ]]; then
clear
systemctl enable sshd
fi
if [[ $selectedSSHMenu == 3 ]]; then
clear
systemctl stop sshd
fi
if [[ $selectedSSHMenu == 4 ]]; then
clear
systemctl restart sshd
fi
}
function start_ssh_client() {
clear
echo "$FG_GREEN
"
read -p "Enter Port: " mySSHport
read -p "Enter host (ex: user@server-address): " mySSHhost
echo "$MODE_BOLD ## ssh -p port user@server-address $FG_NoColor $FG_GREEN"
ssh -p $mySSHport $mySSHhost
echo "$FG_NoColor"
}
function dissconnect_accesspoint() {
dialogBackTitle="nmcli-menu"
dialogTitle="Disconnect from Wifi Accesspoint"
declare -a nmcliArray
nmcliArray=($(nmcli -c no -m tabular -f SSID dev wifi))
declare -a menuArray
for ((i=1; i<${#nmcliArray[@]}; i+=1)); do
rawVal=${nmcliArray[$i]}
cleanedVal=${rawVal// /}
menuArray+=("$(($i))" "$cleanedVal" )
done
selectedWifi=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--menu "wifi list" \
12 50 ${#nmcliArray[@]} \
${menuArray[@]}
) || return
ssidName=$(echo "${nmcliArray[$(($selectedWifi))]}" | xargs)
nmcli connection down $ssidName
}
function delete_accesspoint() {
## nmcli connection delete id <connection name>
echo ""
}
function go_offline() {
echo "# systemctl stop ssh"
systemctl stop ssh
echo "# nmcli radio off"
nmcli radio off
echo "# nmcli networking off"
nmcli networking off
echo "# systemctl stop NetworkManager"
systemctl stop NetworkManager
}
function exit_summary() {
## Display Network State
clear
echo "5 sec delay"
sleep 5s
clear
reset
# ip a
echo "$BG_CYAN
Display networking state: "
echo -e ''$_{1..80}'\b ' $STYLES_OFF
echo "$MODE_BOLD ## nmcli dev status $STYLES_OFF"
nmcli dev status
echo "$MODE_BOLD ## nmcli radio $STYLES_OFF"
nmcli radio
echo "$MODE_BOLD ## systemctl status sshd $STYLES_OFF"
systemctl status sshd
echo "$MODE_BOLD ## nmcli con show $STYLES_OFF"
nmcli con show
echo ""; echo "$MODE_BOLD ## cat /etc/NetworkManager/system-connections/Network $STYLES_OFF
view and mod your connections points "
read -p "$BG_GREEN
presss any key to continue ...
$STYLES_OFF" exitVar
## clear user defined bash vars and history
exec bash
}
function main_connection_menu() {
# sudo systemctl start NetworkManager
dialogBackTitle="Network Manager"
dialogTitle="Access Point Options"
selectedMenuItem=$(dialog 2>&1 >/dev/tty \
--backtitle "$dialogBackTitle" \
--title "$dialogTitle" \
--cancel-label "Back" \
--menu "Select network option:" 14 45 7 \
"1" "Connect to SSID" \
"2" "New Access Point"\
"3" "SSH Server"\
"4" "Start SSH Client"\
"5" "Dissconnect Access Point"\
"6" "Delete Access Point"\
"7" "Go Offline"\
"8" "Display Network State") || return
if [[ $selectedMenuItem == 1 ]]; then
clear
nmcli_wifi_connect
fi
if [[ $selectedMenuItem == 2 ]]; then
clear
new_access_point
fi
if [[ $selectedMenuItem == 3 ]]; then
clear
sshd_service
systemctl status sshd
fi
if [[ $selectedMenuItem == 4 ]]; then
clear
start_ssh_client
fi
if [[ $selectedMenuItem == 5 ]]; then
clear
dissconnect_accesspoint
fi
if [[ $selectedMenuItem == 6 ]]; then
clear
delete_accesspoint
fi
if [[ $selectedMenuItem == 7 ]]; then
clear
go_offline
fi
if [[ $selectedMenuItem == 8 ]]; then
clear
exit_summary
fi
}
decorativeColors
sudo systemctl start NetworkManager
sudo systemctl start dhcpcd.service
main_connection_menu
exit_summary
bash
xorg
xterm
xorg-twm
xorg-xinit
xorg-server
xorg-server-utils
xorg-apps
xorg-xrandr
xorg-xclock
xorg-fonts-misc
grep
sed
wget
gawk
bc
curl
ncurses
dialog
jq
gcc
net-tools
networkmanager
openssh
macchanger
hostapd
iptables
nftables
create_ap
dkms
htop
screenfetch
acpi
acpid
apcupsd
p7zip
lshw
exa
gcc
cmake
extra-cmake-modules
mesa lib32-mesa
xf86-video-intel
arandr
alsa
alsa-utils
pulseaudio
pulseaudio-alsa
vorbis-tools
elinks
git
terminus-font
adobe-source-code-pro-fonts
ttf-ubuntu-font-family
python2-xdg
openbox
openbox-themes
obconf
gtk2
gtk3
pcmanfm
udisks
gvfs
tint2
xterm
zsh
mc
termite
dmenu
geany
geany-plugins
leafpad
feh
conky
nodejs
npm
net-tools
networkmanager
openssh
macchanger
hostapd
iptables
nftables
create_ap
screenfetch
dkms
htop
screenfetch
acpi
apcupsd
p7zip
lshw
tree
elinks
surf
cmake
extra-cmake-modules
mplayer
libreoffice-fresh
java-runtime-common
jdk-openjdk
jre-openjdk
gimp
pinta
imagemagick
bdf-unifont
ttf-bitstream-vera
ttf-ubuntu-font-family
ttf-liberation
ttf-freefont
ttf-inconsolata
adobe-source-code-pro-fonts
arc-gtk-theme
arc-icon-theme
marked
jq
cmatrix
xfce4
xfce4-goodies
thunar-archive-plugin
thunar-media-tags-plugin
thunar-volman
file-roller
xfwm4
xarchiver
#!/bin/sh
## ~/.xinitrc
exec openbox-session
## sudo pacman -S xfce4 xfce4-goodies xfwm4 xarchiver
## startxfce4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment