Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #DEVICES=" aic_200w aic_230w aic_hq gwl2010_470 gwl2010_868 gwl2010_915 gwl2110_470 gwl2110_868 gwl2110_915 hmi2002_070c hmi2002_101c hmi2020_070c hmi2020_101c hmi2120_070c hmi2120_101c hmi2220-070c hmi2220-101c hmi232x_backlight_f hmi232x_backlight_r hmi2610_101c hmi2620_101c hmi2630_101c hmi3010_070c hmi3010_101c hmi3020_070c hmi3020_101c hmi3120_070c hmi3120_101c hmi332x_backlight_f hmi332x_backlight_r hmi3610_101c hmi3620_101c hmi3630_101c ind ipc2010 ipc2110 ipc2200 ipc2410 ipc2420 ipc2430 ipc2610 ipc2620 ipc2630 ipc3020 ipc3110 ipc3610 ipc3620 ipc3630 plc2010 sbc231x sbc331x sen"
- DEVICES="hmi2002_101c"
- #TIMEOUT=30
- #BASE_URL=https://apt.edatec.cn/bsp
- TMP_PATH="$HOME/eda-common"
- # if [ $# -ne 1 ];then
- # echo "Please specify the target."
- # exit 1
- # fi
- #TARGET=$1
- TARGET=$DEVICES
- function log_error(){
- echo "log_error Function reached"
- read
- local msg=$1
- echo -e "\033[31m ${msg} \033[0m"
- }
- function log_info(){
- echo "log_info Function reached"
- read
- local msg=$1
- echo -e "\033[32m ${msg} \033[0m"
- }
- function load_json(){
- echo "load_json Function reached"
- read
- case $# in
- 2)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"'])"
- ;;
- 3)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"'])"
- ;;
- 4)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"']['"$4"'])"
- ;;
- 5)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"']['"$4"']['"$5"'])"
- ;;
- 6)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"']['"$4"']['"$5"']['"$6"'])"
- ;;
- 7)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"']['"$4"']['"$5"']['"$6"']['"$7"'])"
- ;;
- 8)
- echo $1 | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"$2"']['"$3"']['"$4"']['"$5"']['"$6"']['"$7"']['"$8"'])"
- ;;
- esac
- # python3 -c "import sys, json; data=json.load(sys.stdin); print(data['test']['target'])
- }
- function is_in_json(){
- echo "is_in_json Function reached"
- read
- local t_data=$1
- local t_key=$2
- echo $t_data | python3 -c "import sys, json; data=json.load(sys.stdin); print('"${t_key}"' in data)"
- }
- function load_json_len(){
- echo "load_json Function reached"
- read
- local t_data=$1
- local t_key=$2
- echo $t_data | python3 -c "import sys, json; data=json.load(sys.stdin); print(len(data['"${t_key}"']))"
- }
- function load_json_array(){
- echo "load_json Function reached"
- read
- local t_data=$1
- local t_key=$2
- local t_index=$3
- echo $t_data | python3 -c "import sys, json; data=json.load(sys.stdin); print(data['"${t_key}"']["${t_index}"])"
- }
- function run_cmd(){
- echo "run_cmd Function reached arg1== " $1
- read
- local cmd=$1
- log_info "[DEBUG] ${cmd}"
- eval "$cmd"
- }
- function install_eda(){
- echo "install_eda Function reached"
- read
- local tmp_dir="${TMP_PATH}/eda/"
- #mkdir -p $tmp_dir
- #wget "${BASE_URL}/splash.png" -O "${tmp_dir}splash.png"
- #install -m 644 "${tmp_dir}splash.png" "/usr/share/plymouth/themes/pix/"
- local code_name=$(cat /etc/os-release | grep VERSION_CODENAME=)
- local cmd_file="/boot/firmware/cmdline.txt"
- code_name=${code_name#VERSION_CODENAME=}
- if [ "${code_name}" = "bookworm" ];then
- cmd_file="/boot/firmware/cmdline.txt"
- else
- cmd_file="/boot/cmdline.txt"
- fi
- grep -q "net.ifnames=0" ${cmd_file} || sed -i "1{s/$/ net.ifnames=0/}" ${cmd_file}
- echo $cmd_file " cmd_file "
- read
- #NOPE
- #wget "https://apt.edatec.cn/pubkey.gpg" -O "${tmp_dir}edatec.gpg"
- #cat ${tmp_dir}edatec.gpg | gpg --dearmor > "/etc/apt/trusted.gpg.d/edatec-archive-stable.gpg"
- #echo "deb https://apt.edatec.cn/raspbian stable main" | sudo tee /etc/apt/sources.list.d/edatec.list
- #sudo apt update
- }
- function start(){
- echo "start Function reached arg?: " $?
- read
- #local data=$(curl ${BASE_URL}/devices/${TARGET}.json --connect-timeout ${TIMEOUT})
- #if [ $? -ne 0 ];then
- # echo "Load device info failed."
- # exit 2
- #fi
- echo "calling Function install-eda"
- read
- install_eda
- local b_state=$(is_in_json "${data}" "debs")
- echo " b_state " $b_state " Data: " $data
- read
- if [ "${b_state}" == "True" ];then
- local debs=$(load_json "${data}" "debs")
- echo $debs=$(load_json "${data}" "debs")
- read
- log_info "[DEBUG] apt install -y ${debs}"
- echo $log_info "[DEBUG] apt install -y ${debs}"
- read
- #sudo apt install -y ${debs}
- if [ $? -ne 0 ];then
- log_error "Failed to install package"
- #exit 1
- fi
- fi
- b_state=$(is_in_json "${data}" "cmd")
- if [ "${b_state}" == "True" ];then
- local t_len=$(load_json_len "${data}" "cmd")
- index=0
- for i in $(seq 0 $((${t_len} -1)));do
- t_cmd=$(load_json_array "${data}" "cmd" $i)
- run_cmd "${t_cmd}"
- done
- fi
- echo " reboot? lol no"
- read
- # reboot
- }
- function useage(){
- #log_info "curl -s ${BASE_URL}/ed-install.sh | sudo bash -s <device name>"
- #log_info "Suport device:"
- #for d in ${DEVICES[@]}
- #do
- # log_info " ${d}"
- #done
- echo " potential missuse lol "
- read
- }
- if [ -z "${TARGET}" ]; then
- log_error "Please specify the target."
- useage
- else
- if [ -n "${DEVICES}" ];then
- echo "${DEVICES}" | grep -q "${TARGET}"
- if [ $? -eq 0 ];then
- start $TARGET
- else
- log_error "Unknown target."
- useage
- fi
- else
- start $TARGET
- fi
- # start $TARGET
- fi
- #POSINST
- echo " postinstal reached"
- read
- CODENAME=$(cat /etc/os-release | grep VERSION_CODENAME=)
- CODENAME=${CODENAME#VERSION_CODENAME=}
- CONFIG_FILE="/boot/firmware/config.txt"
- if [ "${CODENAME}" = "bookworm" ];then
- CONFIG_FILE="/boot/firmware/config.txt"
- if [ ! -f "$CONFIG_FILE" ];then
- exit 0
- fi
- else
- CONFIG_FILE="/boot/config.txt"
- if [ ! -f "$CONFIG_FILE" ];then
- exit 0
- fi
- fi
- auto_add(){
- local value=$1
- grep -q "^${value}" $CONFIG_FILE
- if [ $? -ne 0 ];then
- sed -i '$a '"${value}" $CONFIG_FILE
- fi
- }
- write_ini(){
- local t_user=$1
- mkdir -p /home/${t_user}/.config
- cat > /home/${t_user}/.config/wayfire.ini << EOF
- [command]
- repeatable_binding_volume_up = KEY_VOLUMEUP
- command_volume_up = wfpanelctl volumepulse volu
- repeatable_binding_volume_down = KEY_VOLUMEDOWN
- command_volume_down = wfpanelctl volumepulse vold
- binding_mute = KEY_MUTE
- command_mute = wfpanelctl volumepulse mute
- binding_menu = <super>
- command_menu = wfpanelctl smenu menu
- binding_terminal = <ctrl> <alt> KEY_T
- command_terminal = lxterminal
- binding_bluetooth = <ctrl> <alt> KEY_B
- command_bluetooth = wfpanelctl bluetooth menu
- binding_netman = <ctrl> <alt> KEY_W
- command_netman = wfpanelctl netman menu
- binding_grim = KEY_SYSRQ
- command_grim = grim
- binding_orca = <ctrl> <alt> KEY_SPACE
- command_orca = gui-pkinst orca reboot
- binding_quit = <ctrl> <alt> KEY_DELETE
- command_quit = lxde-pi-shutdown-helper
- binding_power = KEY_POWER
- command_power = pwrkey
- [input-device:generic ft5x06 (79)]
- output = DSI-1
- [input-device:generic ft5x06 (80)]
- output = DSI-1
- [input-device:FT5406 memory based driver]
- output = DSI-1
- [input]
- xkb_model = pc105
- xkb_layout = gb
- xkb_variant =
- [output:DSI-1]
- mode = 800x1280@40000
- position = 0,0
- transform = 90
- [input-device:Goodix Capacitive TouchScreen]
- output = DSI-1
- [input-device:10-0014 Goodix Capacitive TouchScreen]
- output = DSI-1
- [window-rules]
- rule-1 = on created if title is "LXTerminal" then maximize
- EOF
- chown -R ${t_user}:${t_user} /home/${t_user}/.config
- }
- do_labwc(){
- local t_user=$1
- mkdir -p /home/${t_user}/.config/
- mkdir -p /home/${t_user}/.config/labwc
- mkdir -p /home/${t_user}/.config/kanshi
- cat > /home/${t_user}/.config/kanshi/config << EOF
- profile {
- output DSI-1 mode 800x1280 position 0,0 transform 90
- }
- EOF
- cat > /home/${t_user}/.config/labwc/rc.xml << EOF
- <?xml version='1.0' encoding='UTF-8'?>
- <openbox_config xmlns="http://openbox.org/3.4/rc">
- <touch deviceName="10-0014 Goodix Capacitive TouchScreen" mapToOutput="DSI-1" />
- </openbox_config>
- EOF
- chown -R ${t_user}:${t_user} /home/${t_user}/.config
- }
- write_ini_auto(){
- if [ -f "/usr/bin/labwc" ];then
- raspi-config nonint do_wayland W3
- fi
- for t_user in `ls /home/`
- do
- if [ -d "/home/${t_user}" ];then
- if [ -f "/usr/bin/labwc" ];then
- do_labwc ${t_user}
- fi
- write_ini "${t_user}"
- fi
- done
- }
- start(){
- auto_add "dtoverlay=vc4-kms-dsi-rzw-t101p136cq-rpi4-2lane,interrupt=2"
- auto_add "dtoverlay=imx219"
- echo "" >> $CONFIG_FILE
- if [ "${CODENAME}" = "bookworm" ];then
- write_ini_auto
- fi
- }
- start
- ############## fix post install #################
- :'
- #validate users with getent
- for t_user in $(getent passwd | awk -F: '$6 ~ /^\/home\// {print $1}'); do
- if [ -d "/home/${t_user}" ]; then
- if [ -f "/usr/bin/labwc" ]; then
- do_labwc "${t_user}"
- fi
- write_ini "${t_user}"
- fi
- done
- '
- :'
- # this is only really compable with bookworm though its not clearly stated
- if ! grep -q 'VERSION_CODENAME=bookworm' /etc/os-release; then
- echo "Unsupported OS version. Exiting." >&2
- exit 1
- fi
- '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement