mirror of
https://gitlab.com/JKANetwork/JKArch.git
synced 2026-02-16 10:11:32 +01:00
Backup. WIP of new python script
This commit is contained in:
52
installer/prepare.sh
Normal file
52
installer/prepare.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
##Script that prepares a ArchLinux iso for installing JKArch
|
||||
# Prepare system for install
|
||||
echo "Dont run this"
|
||||
exit
|
||||
if [[ ! -f "jkarch" ]];then
|
||||
#Prepare system before install
|
||||
dialog --title "JKArch install script" --msgbox "Starting installation, please wait" 15 60
|
||||
# First add exec permisson to me
|
||||
chmod +x installer.sh
|
||||
# Grow cowspace
|
||||
comm "Grow cowspace for installer" "1" "sudo" "mount -o remount,size=700M /run/archiso/cowspace"
|
||||
|
||||
#Enable pacman
|
||||
pacman-key --init
|
||||
pacman-key --populate
|
||||
pacman -Sy archlinux-keyring --noconfirm
|
||||
|
||||
pacman -S reflector --noconfirm
|
||||
reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist
|
||||
|
||||
#Delete programs (For not updating it)
|
||||
sudo pacman -R clonezilla darkhttpd diffutils grml-zsh-config irssi linux-atm lvm2 man-db man-pages mc ndisc6 nmap smartmontools testdisk vi vim vim-runtime openconnect pcsclite python2 --noconfirm
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
|
||||
#Needed progs (gparted,python)
|
||||
sudo pacman -S gparted xf86-video-vesa xorg-xinit lwm xorg-xrandr xterm --noconfirm --needed
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
sudo pacman -S python python-pythondialog --noconfirm --needed
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
#Update progs
|
||||
sudo pacman -Su --noconfirm --ignore linux #Do not upgrade kernel automatically
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
sudo rm /etc/X11/xinit/xinitrc
|
||||
sudo touch /etc/X11/xinit/xinitrc
|
||||
sudo chmod 777 /etc/X11/xinit/xinitrc
|
||||
sudo echo "#Start gparted with startx command" > /etc/X11/xinit/xinitrc
|
||||
sudo echo "lwm &" >> /etc/X11/xinit/xinitrc
|
||||
sudo echo "xrandr -s 1024x768 -r 60" >> /etc/X11/xinit/xinitrc
|
||||
sudo echo "xterm -e '/usr/bin/python3 /root/installer.py' -geometry 120x35" >> /etc/X11/xinit/xinitrc
|
||||
sudo chmod 644 /etc/X11/xinit/xinitrc
|
||||
sudo rm -rf /var/cache/pacman/pkg/*
|
||||
|
||||
# No black screensaver
|
||||
setterm -blank 0 -powerdown 0 -powersave off
|
||||
|
||||
# System prepared, now start installer
|
||||
touch /root/jkarch
|
||||
startx
|
||||
#Exit this.
|
||||
exit
|
||||
fi
|
||||
122
installer/python/installer.py
Normal file
122
installer/python/installer.py
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/python3
|
||||
## This script requires ArchLinux, reflector, python3 and python-pythondialog
|
||||
|
||||
###### THIS SCRIPT NOT WORKS, ITS A TRY, THANKS ######
|
||||
print ('\033[91m'+"Dont run this."+'\033[0m')
|
||||
import sys; sys.exit(0)
|
||||
|
||||
import os, subprocess
|
||||
from dialog import Dialog
|
||||
dialog = Dialog(dialog="dialog")
|
||||
FNULL = open(os.devnull, 'w')
|
||||
|
||||
# Import colors for printing
|
||||
class bcolors:
|
||||
PNK = '\033[95m' # Pink
|
||||
BLU = '\033[94m' # Blue
|
||||
GRE = '\033[92m' # Green
|
||||
YEL = '\033[93m' # Yellow
|
||||
RED = '\033[91m' # Red
|
||||
END = '\033[0m' # Default?
|
||||
|
||||
def disable(self):
|
||||
self.PNK = ''
|
||||
self.BLU = ''
|
||||
self.GRE = ''
|
||||
self.YEL = ''
|
||||
self.RED = ''
|
||||
self.END = ''
|
||||
|
||||
# Function to pause program to wait for the user
|
||||
def pause():
|
||||
input('Press <ENTER> to continue')
|
||||
|
||||
# Exec command, returns status of command
|
||||
def execC(command,out="",err=""):
|
||||
#Example: execC('ls -l')
|
||||
if out == "" and err == "":
|
||||
return subprocess.call(command, shell=True)
|
||||
elif out != "" and err == "":
|
||||
return subprocess.call(command, shell=True, stdout=out)
|
||||
elif out != "" and err != "":
|
||||
return subprocess.call(command, shell=True, stdout=out, stderr=err)
|
||||
|
||||
# This funcion clears screen
|
||||
def clear():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
# This funcion show a "dialog-like" message
|
||||
def mostrardialog(title,msg):
|
||||
#Example: mostrardialog("Titulo","Mensaje")
|
||||
dialog.set_background_title("JKArch installer")
|
||||
res = dialog.msgbox(msg, title=title)
|
||||
clear()
|
||||
return res
|
||||
|
||||
# This function shows a yesnobox that return a dialog.OK or dialog.CANCEL
|
||||
def yesnobox(msg):
|
||||
#Example: response = yesnobox("¿Estás de acuerdo?")
|
||||
dialog.set_background_title("JKArch installer")
|
||||
res = dialog.yesno(msg)
|
||||
clear()
|
||||
return res
|
||||
|
||||
def menudialog(title,options):
|
||||
#Example: res = menudialog("Elige",[("Li","Linux","W","Windows")])
|
||||
code, tag = dialog.menu("Some text that will be displayed above the menu entries", choices=options)
|
||||
clear()
|
||||
return tag
|
||||
|
||||
# This function runs a command and shows result. Also can be silent or not silent
|
||||
# multicmd is 0 as unique, 1 as first, 2 as middle, and 3 as last
|
||||
# runas can be sudo, chroot, and chuser
|
||||
# If silent = 0 -> show all; 1 -> silent command; 2 -> Output good ever (And silent)
|
||||
def comm(msg,silent,runas,command,multicmd=0):
|
||||
#Example: comm("Directory list",0,"sudo","ls -l")
|
||||
if runas == "chroot":
|
||||
command="chroot /mnt /bin/bash -c \""+command+"\""
|
||||
elif runas == "chuser":
|
||||
command="chroot /mnt /bin/bash -c \"su $nameuser -c \""+command+"\" \" "
|
||||
if multicmd == 0 or multicmd == 1:
|
||||
print ("[RUNNING] " + msg)
|
||||
if silent == 0:
|
||||
statusC = execC(command)
|
||||
elif silent == 1:
|
||||
statusC = execC(command,FNULL)
|
||||
elif silent == 2:
|
||||
statusC = execC(command,FNULL,FNULL)
|
||||
|
||||
if (statusC == 0 or silent == 2) and (multicmd == 0 or multicmd == 3):
|
||||
print ("["+bcolors.GRE +" OK "+bcolors.END +"] " + msg)
|
||||
elif statusC != 0:
|
||||
print ("["+bcolors.RED +"FAILED"+bcolors.END +"] " + msg)
|
||||
|
||||
|
||||
comm("Directory list",0,"sudo","ls -l")
|
||||
comm("Directory list",1,"sudo","ls -l")
|
||||
response = yesnobox("¿Estás de acuerdo con usar Python?")
|
||||
if response == dialog.OK:
|
||||
print ("Estas avisado.")
|
||||
|
||||
|
||||
|
||||
|
||||
###Start install
|
||||
sclang = menudialog("Selecciona el idioma",[("es","Español","en","Ingles")])
|
||||
execC("loadkeys "+sclang,FNULL,FNULL)
|
||||
comm("Desmontando particiones",2,"sudo","umount /mnt/*/* & umount /mnt/* & umount /mnt")
|
||||
usr_partitions
|
||||
usr_date
|
||||
usr_selectapps
|
||||
usr_userpass
|
||||
|
||||
## TODO RESUMEN ##
|
||||
|
||||
installconf
|
||||
|
||||
usr_otheropts
|
||||
|
||||
mostrardialog("End","Setup finished, press enter to reboot")
|
||||
execC("mv /tmp/install.log /mnt/home/$nameuser/install.log",FNULL)
|
||||
comm("Desmontando particiones",2,"sudo","umount /mnt/*/* & umount /mnt/* & umount /mnt")
|
||||
execC("reboot")
|
||||
Reference in New Issue
Block a user