jetbrains

This commit is contained in:
j3d1 2021-03-12 14:25:29 +01:00
parent 96da07dadb
commit d0db77c036

View file

@ -1,40 +1,54 @@
#!/bin/bash #!/bin/bash
function user_install(){
wget --show-progress -qO ./toolbox.tar.gz https://download.jetbrains.com/toolbox/jetbrains-toolbox-1.20.7940.tar.gz
TOOLBOX_TEMP_DIR=$(mktemp -d)
tar -C "$TOOLBOX_TEMP_DIR" -xf toolbox.tar.gz
rm ./toolbox.tar.gz
"$TOOLBOX_TEMP_DIR"/*/jetbrains-toolbox
rm -r "$TOOLBOX_TEMP_DIR"
}
function first_stage(){ function first_stage(){
set -e set -e
echo foo first_stage echo foo first_stage
echo -n "hostname: " echo -n "hostname: "
read -s hostname_in read -s hostname_in
export NEW_HOSTNAME=$hostname_in export NEW_HOSTNAME=$hostname_in
echo echo
echo -n "luks password: " echo -n "luks password: "
read -s luks_password_in read -s luks_password_in
export LUKS_PASSWORD=$luks_password_in export LUKS_PASSWORD=$luks_password_in
echo echo
echo -n "root password: " echo -n "root password: "
read -s root_password_in read -s root_password_in
export ROOT_PASSWORD=$root_password_in export ROOT_PASSWORD=$root_password_in
echo echo
echo -n "user password: " echo -n "user password: "
read -s user_password_in read -s user_password_in
export USER_PASSWORD=$user_password_in export USER_PASSWORD=$user_password_in
echo echo
lsblk -ftpo NAME,FSTYPE,LABEL,UUID,FSAVAIL,MOUNTPOINT lsblk -ftpo NAME,FSTYPE,LABEL,UUID,FSAVAIL,MOUNTPOINT
select DEVICE in $(lsblk -frpno NAME); do select DEVICE in $(lsblk -frpno NAME); do
echo using $DEVICE echo using $DEVICE
break break
done done
export DEVICE export DEVICE
apt install -y debootstrap cryptsetup btrfs-progs lvm2 apt install -y debootstrap cryptsetup btrfs-progs lvm2
if [ -d /dev/vg0 ]; then if [ -d /dev/vg0 ]; then
mount | grep target | awk '{print $3}'| sort -r | while read LINE; do mount | grep target | awk '{print $3}'| sort -r | while read LINE; do
umount -l $LINE; umount -l $LINE;
@ -44,13 +58,13 @@ function first_stage(){
fi fi
vgchange -an /dev/vg0 vgchange -an /dev/vg0
fi fi
if [ -b /dev/mapper/cryptlvm ]; then if [ -b /dev/mapper/cryptlvm ]; then
cryptsetup luksClose cryptlvm cryptsetup luksClose cryptlvm
fi fi
wipefs -a ${DEVICE} wipefs -a ${DEVICE}
( (
echo o echo o
echo n echo n
@ -65,10 +79,10 @@ function first_stage(){
echo echo
echo w echo w
) | fdisk ${DEVICE} ) | fdisk ${DEVICE}
echo mkfs.ext4 ${DEVICE}1 echo mkfs.ext4 ${DEVICE}1
yes | mkfs.ext4 ${DEVICE}1 yes | mkfs.ext4 ${DEVICE}1
( (
echo $LUKS_PASSWORD echo $LUKS_PASSWORD
echo $LUKS_PASSWORD echo $LUKS_PASSWORD
@ -77,30 +91,30 @@ function first_stage(){
unset LUKS_PASSWORD unset LUKS_PASSWORD
pvcreate /dev/mapper/cryptlvm pvcreate /dev/mapper/cryptlvm
vgcreate vg0 /dev/mapper/cryptlvm vgcreate vg0 /dev/mapper/cryptlvm
export LVM_SIZE=$(dev_size /dev/mapper/cryptlvm) export LVM_SIZE=$(dev_size /dev/mapper/cryptlvm)
export SWAP_SIZE=$(($(mem_size)/1024/1024)) export SWAP_SIZE=$(($(mem_size)/1024/1024))
export ROOT_SIZE=$(($LVM_SIZE/1024/1024-$SWAP_SIZE-512)) export ROOT_SIZE=$(($LVM_SIZE/1024/1024-$SWAP_SIZE-512))
echo lvcreate /dev/vg0 --name=root --size=${ROOT_SIZE}M echo lvcreate /dev/vg0 --name=root --size=${ROOT_SIZE}M
lvcreate /dev/vg0 --name=root --size=${ROOT_SIZE}M lvcreate /dev/vg0 --name=root --size=${ROOT_SIZE}M
yes | mkfs.btrfs /dev/vg0/root yes | mkfs.btrfs /dev/vg0/root
echo lvcreate /dev/vg0 --name=swap --size=${SWAP_SIZE}M echo lvcreate /dev/vg0 --name=swap --size=${SWAP_SIZE}M
lvcreate /dev/vg0 --name=swap --size=${SWAP_SIZE}M lvcreate /dev/vg0 --name=swap --size=${SWAP_SIZE}M
mkswap /dev/vg0/swap mkswap /dev/vg0/swap
swapon /dev/vg0/swap swapon /dev/vg0/swap
echo mount /dev/vg0/root $TARGET echo mount /dev/vg0/root $TARGET
mount /dev/vg0/root $TARGET mount /dev/vg0/root $TARGET
echo debootstrap sid $TARGET echo debootstrap sid $TARGET
debootstrap sid $TARGET debootstrap sid $TARGET
mount ${DEVICE}1 $TARGET/boot mount ${DEVICE}1 $TARGET/boot
echo mount ${DEVICE}1 $TARGET/boot echo mount ${DEVICE}1 $TARGET/boot
genfstab -U $TARGET | tee $TARGET/etc/fstab genfstab -U $TARGET | tee $TARGET/etc/fstab
UUID=$(lsblk -lpo NAME,UUID | grep ${DEVICE}2 | awk '{print $2}') UUID=$(lsblk -lpo NAME,UUID | grep ${DEVICE}2 | awk '{print $2}')
echo cryptlvm UUID=${UUID} none luks > $TARGET/etc/crypttab echo cryptlvm UUID=${UUID} none luks > $TARGET/etc/crypttab
@ -134,7 +148,7 @@ function second_stage(){
echo echo
) | adduser jedi ) | adduser jedi
unset USER_PASSWORD unset USER_PASSWORD
HOME=/home/jedi HOME=/home/jedi
btrfs subvolume snapshot / /snap/$(date +%Y-%m-%d_user_gui) btrfs subvolume snapshot / /snap/$(date +%Y-%m-%d_user_gui)
apt install -y git virt-manager telegram-desktop firefox thunderbird geany vlc pidgin inkscape meld kicad blender apt install -y git virt-manager telegram-desktop firefox thunderbird geany vlc pidgin inkscape meld kicad blender
@ -143,13 +157,16 @@ function second_stage(){
chown -R jedi:jedi $HOME chown -R jedi:jedi $HOME
chsh --shell /bin/zsh jedi chsh --shell /bin/zsh jedi
export -f user_install
su jedi -c "bash -c user_install"
echo second_stage done echo second_stage done
} }
function post_install_stage(){ function post_install_stage(){
sleep 0.5 sleep 0.5
mount | grep target | awk '{print $3}'| sort -r | while read LINE; do mount | grep target | awk '{print $3}'| sort -r | while read LINE; do
umount -l $LINE; umount -l $LINE;
done done
} }