first commit

This commit is contained in:
Your Name
2026-02-07 20:22:48 +08:00
commit 1b9711d5e4
2270 changed files with 805872 additions and 0 deletions

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,177 @@
#!/bin/bash
#
# Copyright (c) Authors: http://www.armbian.com/authors, info@armbian.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#
# check for root privileges
#
if [[ $EUID != 0 ]]; then
echo "This tool requires root privileges. Try again with \"sudo \" please ..." >&2
sleep 2
exit 1
fi
#
# check for internet connection to install dependencies
#
wget -q --spider www.baidu.com
if [[ $? -ne 0 ]]; then
read -n 1 -s -p "Warning: Configuration cannot work properly without a working internet connection. \
Press CTRL C to stop or any key to ignore and continue."
fi
#
# load functions, local first
#
if [[ -f ${BASH_SOURCE}-jobs ]]; then source ${BASH_SOURCE}-jobs;
elif [[ -f /usr/lib/orangepi-config/jobs.sh ]]; then source /usr/lib/orangepi-config/jobs.sh;
else exit 1;
fi
if [[ -f ${BASH_SOURCE}-submenu ]]; then source ${BASH_SOURCE}-submenu;
elif [[ -f /usr/lib/orangepi-config/submenu.sh ]]; then source /usr/lib/orangepi-config/submenu.sh;
else exit 1;
fi
if [[ -f ${BASH_SOURCE}-functions ]]; then source ${BASH_SOURCE}-functions;
elif [[ -f /usr/lib/orangepi-config/functions.sh ]]; then source /usr/lib/orangepi-config/functions.sh;
else exit 1;
fi
if [[ -f ${BASH_SOURCE}-functions-network ]]; then source ${BASH_SOURCE}-functions-network;
elif [[ -f /usr/lib/orangepi-config/functions-network.sh ]]; then source /usr/lib/orangepi-config/functions-network.sh;
else exit 1;
fi
# Script parameters handling
while [[ $1 == *=* ]]; do
parameter=${1%%=*}
value=${1##*=}
shift
echo "Command line: setting $parameter to ${value:-(empty)}"
eval "$parameter=\"$value\""
scripted=true
done
# Display help
if [[ $1 == "--help" ]]; then
echo "Orange Pi config options:"
echo ""
echo "Examples:"
echo ""
echo "Install headers: ${BASH_SOURCE[0]} main=Sytem selection=Headers"
echo "Update, upgrade and reboot: ${BASH_SOURCE[0]} main=System selection=Firmware"
echo "Switch to nightly builds: ${BASH_SOURCE[0]} main=System selection=Nightly"
echo "Switch to stable builds: ${BASH_SOURCE[0]} main=System selection=Stable"
echo "Install default desktop: ${BASH_SOURCE[0]} main=System selection=Default"
echo "Change to ZSH: ${BASH_SOURCE[0]} main=System selection=ZSH"
echo "Change to BASH: ${BASH_SOURCE[0]} main=System selection=BASH"
echo "Change to stable repository [branch=dev]: ${BASH_SOURCE[0]} main=System selection=Stable"
echo "Change to nightly repository [branch=dev]: ${BASH_SOURCE[0]} main=System selection=Nightly"
echo "Install headers: ${BASH_SOURCE[0]} main=Software selection=Headers_install"
echo "Remove headers: ${BASH_SOURCE[0]} main=Software selection=Headers_remove"
echo "Install kernel source: ${BASH_SOURCE[0]} main=Software selection=Source_install"
echo "Remove kernel source: ${BASH_SOURCE[0]} main=Software selection=Source_remove"
echo "Install Avahi mDNS/DNS-SD daemon: ${BASH_SOURCE[0]} main=Software selection=Avahi"
exit
fi
# collect info
main "$@"
#
# Main menu
#
while true
do
LIST=()
LIST+=( "System" "System and security settings" )
LIST+=( "Network" "Wired, wireless, Bluetooth, access point" )
LIST+=( "Personal" "Timezone, language, hostname" )
LIST+=( "Software" "System and 3rd party software install" )
LIST+=( "Help" "Documentation, support, sources" )
# count number of menu items to adjust window size
LISTLENGTH="$((11+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
MENUTITLE="Configure \Z1$DISTRO $DISTROID\Z0"
# read cpu speed
POLICY="policy0"
[[ $(grep -c '^processor' /proc/cpuinfo) -gt 4 ]] && POLICY="policy4"
[[ ! -d /sys/devices/system/cpu/cpufreq/policy4 ]] && POLICY="policy0"
num=$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq 2> /dev/null)
if [[ -f /etc/default/cpufrequtils && ! -z "${num##*[!0-9]*}" ]]; then
LISTLENGTH=$((LISTLENGTH + 2))
MIN_CPU=$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq) / 1000))
MAX_CPU=$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_max_freq) / 1000))
GOVERNOR_CPU=$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_governor)
FREQENCIES="\nSoC runs between \Z1${MIN_CPU}\Z0 and \Z1${MAX_CPU} MHz\Z0 using \Z1${GOVERNOR_CPU}\Z0 governor.\n"
fi
[[ -n "${BOARD_NAME/ /}" ]] && MENUTITLE=$MENUTITLE" based \Z1OrangePi\Z0 for the \Z1${BOARD_NAME}\Z0 "
# main dialog routine
DIALOG_CANCEL=1
DIALOG_ESC=255
TITLELENGTH=${#MENUTITLE}
[[ "$TITLELENGTH" -lt 60 ]] && TITLELENGTH="60"
if [[ -z $main ]]; then
exec 3>&1
main=$(dialog --colors --backtitle "$BACKTITLE" --title " orangepi-config " --clear \
--cancel-label "Exit" --menu "\n$MENUTITLE \n$FREQENCIES\nSupport: \Z1http://www.orangepi.org\Z0\n " \
$LISTLENGTH ${TITLELENGTH} $BOXLENGTH "${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox \
"\nLoading ${main,,} submodule ... " 5 $((26+${#main}))
fi
case $main in
"System" )
submenu_settings
;;
"Network" )
submenu_networking
;;
"Personal" )
submenu_personal
;;
"Software" )
submenu_software
;;
"Help" )
unset main
t="This tool provides a straightforward way of configuring."
t=$t"\n \nAlthough it can be run at any time, some of the"
t=$t" options may have difficulties if you alter system settings manually.\n"
t=$t"\n\Z1Documentation:\Z0 http://www.orangepi.org"
t=$t"\n\n\Z1Support:\Z0 http://www.orangepi.org\n"
t=$t"\n\Z1Sources:\Z0 https://github.com/orangepi-xunlong"
show_box "Info" "$t" "18"
;;
esac
done

View File

@@ -0,0 +1,825 @@
#!/bin/bash
#
# Copyright (c) Authors: http://www.armbian.com/authors, info@armbian.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
# Functions:
# main
# check_desktop
# exceptions
# check_if_installed
# is_package_manager_running
# display_qr_code
# beta_disclaimer
# show_box
# description
# generic_select
# reload_bsp
# other_kernel_version
# aval_dtbs
# get_a20modes
# get_h3modes
# add_choose_user
# google_token_allusers
# configure_desktop
#
# gather info about the board and start with loading menu
#
function main(){
DIALOG_CANCEL=1
DIALOG_ESC=255
# we have our own lsb_release which does not use Python. Others shell install it here
if [[ ! -f /usr/bin/lsb_release ]]; then
if is_package_manager_running; then
sleep 3
fi
debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt -y -qq --allow-downgrades --no-install-recommends install lsb-release
fi
[[ -f /etc/orangepi-release ]] && source /etc/orangepi-release && ORANGEPI="Orange Pi $VERSION $IMAGE_TYPE";
DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -sc)
KERNELID=$(uname -r)
[[ -z "${ORANGEPI// }" ]] && ORANGEPI="$DISTRO $DISTROID"
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | tail -1 | grep -Po '(?<=dev )(\S+)')
LOCALIPADD=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
BACKTITLE="Configuration utility, $ORANGEPI"
[[ -n "$LOCALIPADD" ]] && BACKTITLE=$BACKTITLE", "$LOCALIPADD
TITLE="$BOARD_NAME "
[[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo"
OVERLAYDIR="/boot/dtb/overlay";
[[ "$LINUXFAMILY" == "sunxi64" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
[[ "$LINUXFAMILY" == "meson64" ]] && OVERLAYDIR="/boot/dtb/amlogic/overlay";
[[ "$LINUXFAMILY" == "rockchip64" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay";
[[ "$LINUXFAMILY" == "rockchip-rk3588" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay";
[[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "current" ]] && OVERLAYDIR="/boot/dtb/sunxi/overlay";
[[ "$LINUXFAMILY" == "sun50iw9" && "$BRANCH" == "next" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
[[ "$LINUXFAMILY" =~ "sun55iw3"|"sun60iw2" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
[[ "$LINUXFAMILY" == "rockchip-rk356x" ]] && OVERLAYDIR="/boot/dtb/rockchip/overlay";
[[ "$LINUXFAMILY" == "ky" ]] && OVERLAYDIR="/boot/dtb/ky/overlay";
# detect desktop
check_desktop
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Orange Pi configuration utility ... " 5 45
sleep 1
}
#
# compare two strings in dot separated version format
#
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
#
# test compare two strings $1="3.4.12" $2="5.4.2" $3="<" returns 0 if relation is correct
#
testvercomp () {
vercomp $1 $2
case $? in
0) op='=';;
1) op='>';;
2) op='<';;
esac
if [[ $op != $3 ]]
then
return 1
else
return 0
fi
}
#
# read desktop parameters
#
function check_desktop()
{
DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
check_if_installed nodm && DESKTOP_INSTALLED="nodm";
check_if_installed lightdm && DESKTOP_INSTALLED="lightdm";
check_if_installed gdm && DESKTOP_INSTALLED="gdm";
[[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm"
[[ -n $(service nodm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="nodm"
[[ -n $(service gdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="gdm"
}
#
# naming exceptions for packages
#
function exceptions ()
{
TARGET_FAMILY=$LINUXFAMILY
UBOOT_BRANCH=$TARGET_BRANCH # uboot naming is different
if [[ $TARGET_BRANCH == "default" ]]; then TARGET_BRANCH=""; else TARGET_BRANCH="-"$TARGET_BRANCH; fi
# pine64
if [[ $TARGET_FAMILY == pine64 ]]; then
TARGET_FAMILY="sunxi64"
fi
# allwinner legacy kernels
if [[ $TARGET_FAMILY == sun*i ]]; then
TARGET_FAMILY="sunxi"
if [[ $UBOOT_BRANCH == "default" ]]; then
TARGET_FAMILY=$(cat /proc/cpuinfo | grep "Hardware" | sed 's/^.*Allwinner //' | awk '{print $1;}')
fi
fi
}
#
# check dpkg status of $1 -- currently only 'not installed at all' case caught
#
check_if_installed (){
local DPKG_Status="$(dpkg -s "$1" 2>/dev/null | awk -F": " '/^Status/ {print $2}')"
if [[ "X${DPKG_Status}" = "X" || "${DPKG_Status}" = *deinstall* ]]; then
return 1
else
return 0
fi
}
#
# check if package manager is doing something
#
function is_package_manager_running() {
if ps -C apt-get,apt,dpkg >/dev/null ; then
[[ -z $scripted ]] && dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \
"\n\Z0Package manager is running in the background. \n\nCan't install dependencies. Try again later." 9 53
return 0
else
return 1
fi
}
#
# wget with dialog progress bar $1=URL $2=parameters
#
function fancy_wget()
{
LANG=C wget $2 --progress=bar:force:noscroll $1 2>&1 | stdbuf -i0 -o0 -e0 tr '>' '\n' | \
stdbuf -i0 -o0 -e0 sed -rn 's/^.*\<([0-9]+)%\[.*$/\1/p' | dialog --backtitle "$BACKTITLE" --title " Downloading " \
--gauge "Please wait" 7 70 0
}
#
# display qr code for authentication method
#
function display_qr_code()
{
clear
SECRET=$(head -1 /root/.google_authenticator)
qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$SECRET"
echo -e "\nHow to setup your one type password generator?\n"
echo -e "\nInstall a one-time password authenticator on your mobile device (e.g. FreeOTP) from the Android \
market or F-Droid. \n\nIn the application menu, click the corresponding button to create a new account and either \
scan the QR code or enter the secret key manually:\\n\n$SECRET \n\nYou should now see a new passcode token being \
generated every 60 seconds on your phone.\n" | fold -sw 60
read -n 1 -s -r -p "Press any key to continue"
}
#
# show disclaimer
#
function beta_disclaimer ()
{
exec 3>&1
ACKNOWLEDGEMENT=$(dialog --colors --nocancel --backtitle "$BACKTITLE" --no-collapse --title " Warning " \
--clear \--radiolist "\n$1\n \n" 0 56 5 "Yes, I understand" "" off 2>&1 1>&3)
exec 3>&-
}
#
# show box
#
function show_box ()
{
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --msgbox "\n$2\n \n" $3 56
}
#
# show description for MOTD files
#
function description
{
case $1 in
*header*)
echo "Big board logo and kernel info"
;;
*sysinfo*)
echo "Sysinfo - load, ip, memory, uptime, ..."
;;
*tips*)
echo "Shows tip of the day"
;;
*updates*)
echo "Display number of available updates"
;;
*orangepi-config*)
echo "Show command for system configuration"
;;
*autoreboot-warn*)
echo "Show warning when reboot is needed"
;;
*uk.armbian.com*)
echo "United Kingdom"
;;
*mirrors.tuna.tsinghua.edu.cn/armbian/*)
echo "China"
;;
*mirrors.netix.net/armbian/apt/*)
echo "Bulgarija"
;;
*mirrors.dotsrc.org/armbian-apt/*)
echo "Denmark"
;;
*.armbian.com*)
echo "Estonia"
;;
*)
echo ""
;;
esac
}
#
# Generic select box
#
function generic_select()
{
IFS=$' '
PARAMETER=($1)
local LIST=()
for i in "${PARAMETER[@]}"
do
if [[ -n $3 ]]; then
[[ ${i[0]} -ge $3 ]] && \
LIST+=( "${i[0]//[[:blank:]]/}" "" )
else
LIST+=( "${i[0]//[[:blank:]]/}" "" )
fi
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then
PARAMETER=${PARAMETER[0]}
else
exec 3>&1
PARAMETER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "$2" --clear --menu "" $((6+${LIST_LENGTH})) 0 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# reload kernel, bsp and orangepi-config
#
function reload_bsp(){
# switch to defined branch
[[ -n "$1" ]] && BRANCH=$1
# deal with exceptions
if [[ $BRANCH == current || $BRANCH == dev ]]; then
[[ ${LINUXFAMILY} == rk3399 ]] && LINUXFAMILY=rockchip64
fi
clear
debconf-apt-progress -- apt-get update
# must exits
PACKAGE_INSTALL="linux-image-${BRANCH}-${LINUXFAMILY} linux-dtb-${BRANCH}-${LINUXFAMILY}"
PACKAGE_PURGE="linux-image* linux-dtb*"
# create install and remove logic
command=$(LC_ALL=C apt-get --download-only --simulate --allow-downgrades -y --no-install-recommends install linux-${DISTROID}-root-${BRANCH}-${BOARD} 2>/dev/null)
if [[ $? -eq 0 && -z $(echo $command | grep "not possible") ]]; then
PACKAGE_INSTALL+=" linux-${DISTROID}-root-${BRANCH}-${BOARD}"
PACKAGE_PURGE+=" linux-${DISTROID}-root*"
fi
command=$(LC_ALL=C apt-get --download-only --simulate --reinstall --allow-downgrades -y --no-install-recommends install linux-u-boot-${BOARD}-${BRANCH} 2>/dev/null)
if [[ $? -eq 0 && -z $(echo $command | grep "not possible") ]]; then
PACKAGE_INSTALL+=" linux-u-boot-${BOARD}-${BRANCH}"
PACKAGE_PURGE+=" linux-u-boot-${BOARD}-*"
fi
if check_if_installed orangepi-${DISTROID}-desktop ; then
PACKAGE_INSTALL+=" orangepi-${DISTROID}-desktop"
PACKAGE_PURGE+=" orangepi-${DISTROID}-desktop*"
fi
if check_if_installed linux-headers-${BRANCH}-${FAMILY} ; then
PACKAGE_INSTALL+=" linux-headers-${BRANCH}-${FAMILY}"
PACKAGE_PURGE+=" linux-headers*"
fi
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" --force-yes --download-only --allow-downgrades -y --no-install-recommends install $PACKAGE_INSTALL
# if download is ok, remove old packages
if [[ $? = 0 ]]; then
debconf-apt-progress -- apt-get -y -qq purge $PACKAGE_PURGE
find "/boot/" -name "System.map*" -type f -delete
find "/boot/" -name "config*" -type f -delete
find "/boot/" -name "vmlinuz*" -type f -delete
find "/boot/" -name "*nitrd*" -type f -delete
find "/boot/" -name "*Image" -type l -delete
# install packages
echo $PACKAGE_INSTALL >> /var/log/upgrade.log
debconf-apt-progress -- apt-get -y -qq --allow-downgrades --no-install-recommends --reinstall \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $PACKAGE_INSTALL
if [[ $? -eq 1 ]]; then
echo "Something went wrong ... check logs."; exit;
else
apt clean
fi
fi
}
function other_kernel_version ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
local HIDDEN='hidden'
# get current kernel information
CURRENT_VERSION_TEMP=$(dpkg -l | grep '^ii' | grep linux-image)
CURRENT_VERSION=$(echo $CURRENT_VERSION_TEMP | awk '{print $2}')"="$(echo $CURRENT_VERSION_TEMP | awk '{print $3}')
# Merge families and handle exceptions
[[ ${LINUXFAMILY} == sun*i ]] && LINUXFAMILY=sunxi
[[ ${LINUXFAMILY} == pine64 ]] && LINUXFAMILY=sunxi64
[[ ${LINUXFAMILY} == sun*iw* ]] && LINUXFAMILY=sunxi64
[[ ${LINUXFAMILY} == cubox || ${LINUXFAMILY} == udoo ]] && LINUXFAMILY=imx6
[[ ${BOARD} == odroidc2 || ${BOARD} == kvim1 || ${BOARD} == lafrite || ${BOARD} == lepotato || ${BOARD} == nanopik2-s905 ]] && HIDDEN="legacy"
[[ ${LINUXFAMILY} == odroidn2 ]] && LINUXFAMILY=meson64
# check what is available from the repository
debconf-apt-progress -- apt-get update
LIST=($(apt-cache show linux-image*${LINUXFAMILY} | grep -E "Package:|Version:|version:" \
| grep -v "Config-Version" | sed -n -e 's/^.*: //p' | sed 's/\.$//g'))
new_list=()
# create a human readable menu
for ((n=0;n<$((${#LIST[@]}));n++));
do
m=$(( $n + 1 ))
prvi=$((3*$m - 3))
drugi=$((3*$m - 2))
tretji=$((3*$m - 1))
[[ -z ${LIST[$prvi]} ]] && break
if [[ $CURRENT_VERSION != "${LIST[$prvi]}=${LIST[$drugi]}" && ${LIST[$prvi]} != *${HIDDEN}* ]]; then
new_list+=( "${LIST[$prvi]}=${LIST[$drugi]}" )
new_list+=( ${LIST[$tretji]} )
fi
local tmp="${LIST[$prvi]}=${LIST[$drugi]}${LIST[$tretji]}"
[[ ${#tmp} -gt $chrlen ]] && local chrlen=${#tmp}
done
# copy back to main array
LIST=("${new_list[@]}")
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then
dialog --backtitle "$BACKTITLE" --title " Warning " --msgbox "\nNo other kernels available!" 7 32
else
beta_disclaimer "Switching between kernels might change functionality of your board or it might fail to boot. \
\n\n\Z1In case of troubles expect no help!\Z0"
if [[ -n $ACKNOWLEDGEMENT ]]; then
exec 3>&1
TARGET_VERSION=$(dialog --ok-label "Reboot" --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Select kernel and reboot" --clear --menu "" $((6+${LIST_LENGTH})) $((7+${chrlen})) 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?;
exec 3>&-
if [[ $exitstatus = 0 ]]; then
IFS=" "
# determine upgrade packages
UPGRADE_ROOT="default"
UPGRADE_UBOOT=""
[[ $TARGET_VERSION == *legacy* ]] && UPGRADE_ROOT="-legacy" && UPGRADE_UBOOT="legacy"
[[ $TARGET_VERSION == *next* ]] && UPGRADE_ROOT="-next" && UPGRADE_UBOOT="next"
[[ $TARGET_VERSION == *current* ]] && UPGRADE_ROOT="-current" && UPGRADE_UBOOT="current"
[[ $TARGET_VERSION == *dev* ]] && UPGRADE_ROOT="-dev" && UPGRADE_UBOOT="dev"
# install packages
PACKAGE_LIST="$TARGET_VERSION"
TARGET_VERSION_DTB=${TARGET_VERSION/image/dtb}
TARGET_VERSION_PRE=$(echo $TARGET_VERSION_DTB | cut -f1 -d"=")
TARGET_VERSION_SUB=$(echo $TARGET_VERSION_DTB | cut -f2 -d"=")
[[ -n $(apt-cache madison "$TARGET_VERSION_PRE" | grep $TARGET_VERSION_SUB ) ]] && \
# installs u-boot only if exits
apt-cache show linux-u-boot-${BOARD}-${UPGRADE_UBOOT} 2> /dev/null
[[ $? -eq 0 ]] && PACKAGE_LIST=$PACKAGE_LIST" linux-u-boot-${BOARD}-${UPGRADE_UBOOT}"
PACKAGE_LIST=$PACKAGE_LIST" $TARGET_VERSION_DTB"
echo $PACKAGE_LIST > /tmp/switch_kernel.log 2>&1
debconf-apt-progress -- apt -o Dpkg::Options::="--force-confold" --force-yes --download-only --allow-downgrades -y --no-install-recommends install $PACKAGE_LIST
if [[ $? = 0 ]]; then
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel ..." 5 36
# remove old kernel
debconf-apt-progress -- apt -y -qq purge linux-u-boot* linux-image* linux-dtb* linux-headers* linux-${DISTROID}-root*
# cleanup
find "/boot/" -name "System.map*" -type f -delete; find "/boot/" -name "config*" -type f -delete
find "/boot/" -name "vmlinuz*" -type f -delete; find "/boot/" -name "*nitrd*" -type f -delete
apt clean
# BSP must be installed separate otherwise it won't work
debconf-apt-progress -- apt -o Dpkg::Options::="--force-confold" --force-yes -y -qq --allow-downgrades --no-install-recommends install linux-${DISTROID}-root${UPGRADE_ROOT}-${BOARD}
debconf-apt-progress -- apt -o Dpkg::Options::="--force-confold" --force-yes -y -qq --allow-downgrades --no-install-recommends install $PACKAGE_LIST
if [[ $? = 0 ]]; then
# update boot loader
[[ -f /usr/lib/u-boot/platform_install.sh ]] && source /usr/lib/u-boot/platform_install.sh
#recognize_root
root_uuid=$(sed -e 's/^.*root=//' -e 's/ .*$//' < /proc/cmdline)
root_partition=$(blkid | tr -d '":' | grep "${root_uuid}" | awk '{print $1}')
root_partition_device="${root_partition::-2}"
write_uboot_platform "$DIR" "${root_partition_device}"
reboot
fi
else
dialog --backtitle "$BACKTITLE" --title "Warning" --msgbox \
"\nTest install failed. Can't change firmware \n\nCheck /tmp/switch_kernel.log" 9 48
fi
fi
fi
fi
}
#
# check if board has alternative kernels
#
function aval_dtbs ()
{
if [[ $LINUXFAMILY == cubox ]]; then
local width=80
LIST=("imx6dl-hummingboard.dtb" "HB Solo/DualLite" "imx6dl-hummingboard-emmc-som-v15.dtb" "HB Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard-som-v15.dtb" "HB Solo/DualLite v1.5" \
"imx6dl-hummingboard2.dtb" "HB2 Solo/DualLite" "imx6dl-hummingboard2-emmc-som-v15.dtb" "HB2 Solo/DualLite v1.5 with eMMC" "imx6dl-hummingboard2-som-v15.dtb" "HB2 Solo/DualLite v1.5" \
"imx6q-hummingboard.dtb" "HB Dual/Quad" "imx6q-hummingboard-emmc-som-v15.dtb" "HB Dual/Quad v1.5 with eMMC" "imx6q-hummingboard-som-v15.dtb" "HB Dual/Quad v1.5" \
"imx6q-hummingboard2.dtb" "HB2 Dual/Quad" "imx6q-hummingboard2-emmc-som-v15.dtb" "HB2 Dual/Quad v1.5 with eMMC" "imx6q-hummingboard2-som-v15.dtb" "HB2 Dual/Quad v1.5" \
"imx6dl-cubox-i.dtb" "Cubox-i Solo/DualLite" "imx6dl-cubox-i-emmc-som-v15.dtb" "Cubox-i Solo/DualLite v1.5 with eMMC" "imx6dl-cubox-i-som-v15.dtb" "Cubox-i Solo/DualLite v1.5" \
"imx6q-cubox-i.dtb" "Cubox-i Dual/Quad" "imx6q-cubox-i-emmc-som-v15.dtb" "Cubox-i Dual/Quad v1.5 with eMMC" "imx6q-cubox-i-som-v15.dtb" "Cubox-i Dual/Quad v1.5")
else
local width=52
LIST=("xu4" "Odroid XU4" "xu3" "Odroid XU3" "xu3l" "Odroid XU3 Lite" "hc1" "Odroid HC1/HC2")
fi
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then
TARGET_BOARD=${AVAL_KERNEL[0]}
else
exec 3>&1
TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Select optimised board configuration" --clear --menu \
"" $((6+${LIST_LENGTH})) ${width} 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?;
exec 3>&-
fi
}
#
# select video modes for a10 and a20
#
function get_a20modes ()
{
IFS=$'\r'
GLOBIGNORE='*'
SCREEN_RESOLUTION=("1920x1080p60" "1280x720p60" "1920x1080p50" "1280x1024p60" "1024x768p60" "800x600p60" "640x480p60" "1360x768p60" "1440x900p60" "1680x1050p60")
local LIST=()
for i in "${SCREEN_RESOLUTION[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH
#exit
if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else
exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# select video modes for odroid c1/c2
#
function get_odroidmodes ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep -w "# setenv" | grep "hz" | cut -d'"' -f 2))
SCREEN_RESOLUTION=($(cat /boot/boot.ini | grep "Progressive" | grep -v "setenv" | cut -d'"' -f 2))
local LIST=()
for i in "${SCREEN_RESOLUTION[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH
#exit
if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else
exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# select video modes for h3
#
function get_h3modes ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
SCREEN_RESOLUTION=($(h3disp -i clean))
local LIST=()
for i in "${SCREEN_RESOLUTION[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
#echo $LIST_LENGTH
#exit
if [ "$LIST_LENGTH" -eq 1 ]; then
SCREEN_RESOLUTION=${SCREEN_RESOLUTION[0]}
else
exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# create or pick unprivileged user
#
function add_choose_user ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
local USERS=($(awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd))
local LIST=()
for i in "${USERS[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then
dialog --backtitle "$BACKTITLE" --title " Notice " --msgbox \
"\nWe didn't find any unprivileged user with sudo rights which is required to run this service.\
\n\nPress enter to create one!" 10 48
read -t 0 temp
echo -e "\nPlease provide a username (eg. your forename) or leave blank for canceling user creation: \c"
read -e username
CHOSEN_USER="$(echo "$username" | tr '[:upper:]' '[:lower:]' | tr -d -c '[:alnum:]')"
[ -z "$CHOSEN_USER" ] && return
echo "Trying to add user $CHOSEN_USER"
adduser $CHOSEN_USER || return
elif [ "$LIST_LENGTH" -eq 1 ]; then
CHOSEN_USER=${USERS[0]}
else
exec 3>&1
CHOSEN_USER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select unprivileged user" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# Copy Google token to all local users.
#
function google_token_allusers ()
{
if [[ -f /root/.google_authenticator ]]; then
local USERS=($(awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd))
for i in "${USERS[@]}"
do
USER=${i[0]//[[:blank:]]/}
if [[ -d /home/$USER ]]; then
cp /root/.google_authenticator /home/$USER/
chown ${USER}:${USER} /home/${USER}/.google_authenticator
fi
done
fi
}
#
# configure orangepi desktop
#
function configure_desktop ()
{
add_choose_user
if [ -n "$CHOSEN_USER" ]; then
# update packages
debconf-apt-progress -- apt-get update
# install new package if exists
unset PACKAGE_SUFIX
[[ -n $(apt-cache search --names-only "^orangepi-${DISTROID}-desktop-xfce$") ]] && PACKAGE_SUFIX="-xfce"
# remove desktop package to secure proper install
if check_if_installed orangepi-${DISTROID}-desktop ; then
debconf-apt-progress -- apt-get -y \
remove orangepi-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter
fi
# install desktop package
debconf-apt-progress -- apt-get --reinstall -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" -y \
install $1 orangepi-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter
# in case previous install was interrupted
[[ $? -eq 130 ]] && dpkg --configure -a
# clean apt cache
apt clean
# add user to groups
for additionalgroup in sudo netdev audio video dialout plugdev input bluetooth systemd-journal ssh; do
usermod -aG ${additionalgroup} ${CHOSEN_USER} 2>/dev/null
done
# Prevent loading paralel printer port drivers which we don't need here.
# suppress boot error if kernel modules are absent
if [[ -f /etc/modules-load.d/cups-filters.conf ]]; then
sed "s/^lp/#lp/" -i /etc/modules-load.d/cups-filters.conf
sed "s/^ppdev/#ppdev/" -i /etc/modules-load.d/cups-filters.conf
sed "s/^parport_pc/#parport_pc/" -i /etc/modules-load.d/cups-filters.conf
fi
# enable show windows content on stronger boards
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
if [[ ${cpu_cores} -gt 2 && -f /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml ]]; then
sed -i 's/<property name="box_move" type="bool" value=".*/<property name="box_move" type="bool" value="false"\/>/g' \
/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml
fi
# fix for gksu in Xenial
touch /home/${CHOSEN_USER}/.Xauthority
cp -R /etc/skel/. /home/${CHOSEN_USER}
# set up profile sync daemon on desktop systems
which psd >/dev/null 2>&1
if [[ $? -eq 0 && -z $(grep overlay-helper /etc/sudoers) ]]; then
echo "${CHOSEN_USER} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> /etc/sudoers
touch /home/${CHOSEN_USER}/.activate_psd
fi
mkdir -p /etc/lightdm/lightdm.conf.d
echo "[Seat:*]" > /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
echo "autologin-user=$CHOSEN_USER" >> /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
echo "autologin-user-timeout=0" >> /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
echo "user-session=xfce" >> /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
ln -s /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service >/dev/null 2>&1
# fix permissions
chown -R ${CHOSEN_USER}:${CHOSEN_USER} /home/${CHOSEN_USER}/.
service lightdm start >/dev/null 2>&1
fi
}

View File

@@ -0,0 +1,742 @@
#!/bin/bash
#
# Copyright (c) 2017 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
# Functions:
# initialize_lte
# function lte
# check_hostapd
# check_advanced_modes
# create_if_config
# reload-nety
# check_port
# check_ht_capab
# check_vht_capab
# check_channels
# netmask_to_cidr
# nm_ip_editor
# systemd_ip_editor
# ip_editor
# wlan_edit_basic
# wlan_edit
# wlan_exceptions
# check_and_warn
# get_wlan_interface
# select_default_interface
# connect_bt_interface
#
# 3G/4G general stuff
#
function initialize_lte ()
{
# This file defines udev rules for some 3G/UMTS/LTE modems. It
# addresses the issue that the ttyUSB devices are numbered randomly, and
# their numbering can vary between server reboots. These rules create
# persistent symlinks which can be reliably used in WWAN interface
# startup scripts.
# These rules assume that there is only one WWAN modem in the system. In
# order to address multiple WWAN cards, the rules need to be more
# specific and associate with serial numbers of the modems.
# Copyright (c) 2016 Stanislav Sinyagin <ssinyagin@k-open.com>.
# This content is published under Creative Commons Attribution 4.0
# International (CC BY 4.0) license.
# Source repository: https://github.com/ssinyagin/wwan_udev_rules
if ! check_if_installed ppp then; then
apt-get -y -qq install ppp >/dev/null 2>&1
fi
cat >/etc/udev/rules.d/99-wwan.rules <<'EOT'
# Source repository: https://github.com/ssinyagin/wwan_udev_rules
# Huawei ME909s-120 LTE modem
SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="15c1", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="15c1", NAME="lte0"
# Huawei MU709s-2 UMTS modem
SUBSYSTEM=="tty", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c25", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1c25", NAME="umts0"
# Qualcomm Gobi2000
SUBSYSTEM=="tty", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="251d", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
# Sierra Wireless MC8775
SUBSYSTEM=="tty", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1e1d", SYMLINK+="ttyWWAN%E{.ID_PORT}"
# Novatel Wireless, Inc. Expedite E371
SUBSYSTEM=="tty", ATTRS{idVendor}=="413c", ATTRS{idProduct}=="819b", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
# SIMCom SIM7100
SUBSYSTEM=="tty", ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", SYMLINK+="ttyWWAN%E{ID_USB_INTERFACE_NUM}"
SUBSYSTEM=="net", ATTRS{idVendor}=="1e0e", ATTRS{idProduct}=="9001", NAME="lte0"
EOT
# reload udev rules
udevadm control --reload-rules && udevadm trigger
}
#
# 3G/4G init scripts add + remove
#
function lte ()
{
case $1 in
"12d1:15c1" )
# Huawei ME909s-120 LTE modem
LTE_MODEM_ID=$1
if [[ $2 == on && $(cat /sys/class/net/lte0/operstate) == "up" ]]; then
show_box "Warning" "Huawei ME909s-120 LTE modem is up and running" 7
elif [[ $2 == on ]]; then
show_box "Info" "Huawei ME909s-120 LTE modem will try to connect" 7
cat >/etc/chatscripts/sunrise.HUAWEI <<'EOT'
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
TIMEOUT 10
'' ATZ
OK 'AT+CFUN=1'
OK 'AT+CMEE=1'
OK 'AT\^NDISDUP=1,1,"internet"'
OK
EOT
cat >/etc/chatscripts/gsm_off.HUAWEI <<'EOT'
ABORT ERROR
TIMEOUT 5
'' AT+CFUN=0 OK
EOT
cat >/etc/network/interfaces.d/lte0 <<'EOT'
allow-hotplug lte0
iface lte0 inet dhcp
pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.HUAWEI >/dev/ttyWWAN02 </dev/ttyWWAN02
post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.HUAWEI >/dev/ttyWWAN02 </dev/ttyWWAN02
EOT
# disable interface
ifup lte0 2> /dev/null
elif [[ $2 == off ]]; then
show_box "Warning" "Huawei ME909s-120 LTE will kill connection" 7
# enable interface
ifdown lte0 2> /dev/null
rm /etc/chatscripts/sunrise.HUAWEI
rm /etc/chatscripts/gsm_off.HUAWEI
rm /etc/network/interfaces.d/lte0
elif [[ $(cat /sys/class/net/lte0/operstate) == "up" ]]; then
LTE_MODEM="Huawei ME909s-120 LTE modem is online"
else
LTE_MODEM="Huawei ME909s-120 LTE modem is offline"
fi
;;
esac
}
#
# check hostapd configuration. Return error or empty if o.k.
#
check_hostapd ()
{
systemctl daemon-reload
hostapd_error=""
[[ -n $1 && -n $2 ]] && dialog --title " $1 " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "$2" 5 $((${#2}-3))
service hostapd stop
rm -f /var/run/hostapd/*
sleep 1
service hostapd start
sleep 6
if [[ "$(hostapd_cli ping 2> /dev/null| grep PONG)" == "PONG" ]]; then
hostapd_error=""
else
hostapd_error=$(hostapd /etc/hostapd.conf)
sleep 6
[[ -n $(echo $hostapd_error | grep "channel") ]] && hostapd_error="channel_restriction"
[[ -n $(echo $hostapd_error | grep "does not support" | grep "hw_mode") ]] && hostapd_error="hw_mode"
[[ -n $(echo $hostapd_error | grep "not found from the channel list" | grep "802.11g") ]] && hostapd_error="wrong_channel"
[[ -n $(echo $hostapd_error | grep "VHT") ]] && hostapd_error="unsupported_vht"
[[ -n $(echo $hostapd_error | grep " HT capability") ]] && hostapd_error="unsupported_ht"
fi
}
#
# check all possible wireless modes
#
function check_advanced_modes ()
{
sed '/### IEEE 802.11n/,/^### IEEE 802.11n/ s/^# *//' -i /etc/hostapd.conf
check_hostapd "Probing" "\n802.11n \Z1(150-300Mbps)\Z0"
# check HT capability
check_ht_capab
if [[ -z "$hostapd_error" ]]; then
sed '/### IEEE 802.11a\>/,/^### IEEE 802.11a\>/ s/^# *//' -i /etc/hostapd.conf
sed -i "s/^channel=.*/channel=40/" /etc/hostapd.conf
check_hostapd "Probing" "\n802.11a \Z1(5Ghz)\Z0"
if [[ "$hostapd_error" == "channel_restriction" ]]; then check_channels; fi
if [[ "$hostapd_error" == "channel_restriction" ]]; then
# revering configuration
sed -i "s/^channel=.*/channel=5/" /etc/hostapd.conf
sed '/## IEEE 802.11a\>/,/^## IEEE 802.11a\>/ s/.*/#&/' -i /etc/hostapd.conf
check_hostapd "Reverting" "\nWireless \Z1802.11a (5Ghz)\Z0 is not supported"
else
sed '/### IEEE 802.11ac\>/,/^### IEEE 802.11ac\>/ s/^# *//' -i /etc/hostapd.conf
# check VHT capability
check_vht_capab
if [[ "$hostapd_error" == "unsupported_vht" || "$hostapd_error" == "channel_restriction" ]]; then
# revering configuration
sed '/## IEEE 802.11ac\>/,/^## IEEE 802.11ac\>/ s/.*/#&/' -i /etc/hostapd.conf
check_hostapd "Reverting" "\nWireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0 is not supported"
if [[ "$hostapd_error" == "channel_restriction" ]]; then check_channels; fi
fi
fi
else
sed '/## IEEE 802.11n/,/^## IEEE 802.11n/ s/.*/#&/' -i /etc/hostapd.conf
fi
}
#
# create interface configuration section
#
function create_if_config() {
address=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
netmask=$(ip -4 addr show dev $1 | awk '/inet/ {print $2}' | cut -d'/' -f2)
gateway=$(route -n | grep 'UG[ \t]' | awk '{print $2}' | sed -n '1p')
echo -e "# orangepi-config created"
echo -e "source /etc/network/interfaces.d/*\n"
if [[ "$3" == "fixed" ]]; then
echo -e "# Local loopback\nauto lo\niface lo init loopback\n"
echo -e "# Interface $2\nauto $2\nallow-hotplug $2"
echo -e "iface $2 inet static\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8"
fi
}
#
# reload network related services
#
function reload-nety() {
systemctl daemon-reload
if [[ "$1" == "reload" ]]; then WHATODO="Reloading services"; else WHATODO="Stopping services"; fi
(service network-manager stop >/dev/null 2>&1; service NetworkManager stop >/dev/null 2>&1; echo 10; sleep 1; service hostapd stop; echo 20; sleep 1; service dnsmasq stop; echo 30; sleep 1;\
[[ "$1" == "reload" ]] && service dnsmasq start && echo 60 && sleep 1 && service hostapd start && echo 80 && sleep 1;\
service network-manager start >/dev/null 2>&1; service NetworkManager start >/dev/null 2>&1; echo 90; sleep 5;) | dialog --backtitle "$BACKTITLE" --title " $WHATODO " --gauge "" 6 70 0
systemctl restart systemd-resolved.service
}
#
# Check if something is running on port $1 and display info
#
function check_port ()
{
[[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'$1'"') ]] && dialog --backtitle "$BACKTITLE" --title "Checking service" \
--msgbox "\nIt looks good.\n\nThere is $2 service on port $1" 9 52
}
#
# check wifi high throughput
#
function check_ht_capab ()
{
declare -a arr=("[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40][SMPS-STATIC]" \
"[HT40-][SHORT-GI-40][SHORT-GI-40][DSSS_CCK-40]" "[SHORT-GI-20][SHORT-GI-40][HT40+]" "[DSSS_CK-40][HT20+]" "")
local j=0
for i in "${arr[@]}"
do
j=$((j+(100/${#arr[@]})))
echo $j | dialog --title " Probing HT " --colors --gauge "\nSeeking for optimal \Z1high throughput\Z0 settings." 8 50 0
sed -i "s/^ht_capab=.*/ht_capab=$i/" /etc/hostapd.conf
check_hostapd
if [[ "$hostapd_error" == "channel_restriction" ]]; then check_channels; fi
if [[ "$hostapd_error" == "" ]]; then break; fi
done
}
#
# check wifi high throughput
#
function check_vht_capab ()
{
declare -a arr=("[MAX-MPDU-11454][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP3]" "[MAX-MPDU-11454][SHORT-GI-80][RX-STBC-1][MAX-A-MPDU-LEN-EXP3]" "")
local j=0
for i in "${arr[@]}"
do
j=$((j+(100/${#arr[@]})))
echo $j | dialog --title " Probing VHT " --colors --gauge "\nSeeking for optimal \Z1very high throughput\Z0 settings." 8 54 0
sed -i "s/^vht_capab=.*/vht_capab=$i/" /etc/hostapd.conf
check_hostapd
if [[ "$hostapd_error" == "channel_restriction" ]]; then check_channels; fi
if [[ "$hostapd_error" == "" ]]; then break; fi
done
}
#
# check 5Ghz channels
#
function check_channels ()
{
declare -a arr=("36" "40")
for i in "${arr[@]}"
do
sed -i "s/^channel=.*/channel=$i/" /etc/hostapd.conf
check_hostapd "Probing" "\nChannel:\Z1 ${i}\Z0"
if [[ "$hostapd_error" != "channel_restriction" ]]; then break; fi
done
}
#
# convert netmask to CIDR
#
function netmask_to_cidr ()
{
IFS=' '
local bits=0
for octet in $(echo $1| sed 's/\./ /g'); do
binbits=$(echo "obase=2; ibase=10; ${octet}"| bc | sed 's/0//g')
let bits+=${#binbits}
done
echo "${bits}"
}
#
# edit ip address within network manager
#
function nm_ip_editor ()
{
exec 3>&1
dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1
\n " 12 38 0 \
"Address:" 1 1 "$address" 1 15 15 0 \
"Netmask:" 2 1 "$netmask" 2 15 15 0 \
"Gateway:" 3 1 "$gateway" 3 15 15 0 \
2>&1 1>&3 | {
read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then
localuuid=$(LC_ALL=C nmcli -f UUID,DEVICE connection show | grep $1 | awk '{print $1}')
# convert netmask value to CIDR if required
if [[ $netmask =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
CIDR=$(netmask_to_cidr ${netmask})
else
CIDR=${netmask}
fi
if [[ -n "$localuuid" ]]; then
# adjust existing
nmcli con mod $localuuid ipv4.method manual ipv4.addresses "$address/$CIDR" >/dev/null 2>&1
nmcli con mod $localuuid ipv4.method manual ipv4.gateway "$gateway" >/dev/null 2>&1
nmcli con mod $localuuid ipv4.dns "8.8.8.8,$gateway" >/dev/null 2>&1
nmcli con down $localuuid >/dev/null 2>&1
sleep 2
nmcli con up $localuuid >/dev/null 2>&1
else
# create new
nmcli con add con-name "orangepi" ifname "$1" type 802-3-ethernet ip4 "$address/$CIDR" gw4 "$gateway" >/dev/null 2>&1
nmcli con mod "orangepi" ipv4.dns "8.8.8.8,$gateway" >/dev/null 2>&1
nmcli con up "orangepi" >/dev/null 2>&1
fi
fi
}
}
#
# edit ip address
#
function systemd_ip_editor ()
{
local filename="/etc/systemd/network/10-$1.network"
if [[ -f $filename ]]; then
sed -i '/Network/,$d' $filename
exec 3>&1
dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1
\n " 12 38 0 \
"Address:" 1 1 "$address" 1 15 15 0 \
"Netmask:" 2 1 "$netmask" 2 15 15 0 \
"Gateway:" 3 1 "$gateway" 3 15 15 0 \
2>&1 1>&3 | {
read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then
echo -e "[Network]" >>$filename
echo -e "Address=$address" >> $filename
echo -e "Gateway=$gateway" >> $filename
echo -e "DNS=8.8.8.8" >> $filename
fi
}
fi
}
#
# edit ip address
#
function ip_editor ()
{
exec 3>&1
dialog --title " Static IP configuration" --backtitle "$BACKTITLE" --form "\nAdapter: $1
\n " 12 38 0 \
"Address:" 1 1 "$address" 1 15 15 0 \
"Netmask:" 2 1 "$netmask" 2 15 15 0 \
"Gateway:" 3 1 "$gateway" 3 15 15 0 \
2>&1 1>&3 | {
read -r address;read -r netmask;read -r gateway
if [[ $? = 0 ]]; then
echo -e "# orangepi-config created\nsource /etc/network/interfaces.d/*\n" >$3
echo -e "# Local loopback\nauto lo\niface lo inet loopback\n" >> $3
echo -e "# Interface $2\nauto $2\nallow-hotplug $2\niface $2 inet static\
\n\taddress $address\n\tnetmask $netmask\n\tgateway $gateway\n\tdns-nameservers 8.8.8.8" >> $3
fi
}
}
#
# edit hostapd parameters
#
function wlan_edit_basic ()
{
source /etc/hostapd.conf
exec 3>&1
dialog --title "AP configuration" --backtitle "$BACKTITLE" --form "\nWPA2 enabled, \
advanced config: edit /etc/hostapd.conf\n " 12 58 0 \
"SSID:" 1 1 "$ssid" 1 31 22 0 \
"Password:" 2 1 "$wpa_passphrase" 2 31 22 0 \
"Channel:" 3 1 "$channel" 3 31 3 0 \
2>&1 1>&3 | {
read -r ssid;read -r wpa_passphrase;read -r channel
if [[ $? = 0 ]]; then
sed -i "s/^ssid=.*/ssid=$ssid/" /etc/hostapd.conf
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$wpa_passphrase/" /etc/hostapd.conf
sed -i "s/^channel=.*/channel=$channel/" /etc/hostapd.conf
wpa_psk=$(wpa_passphrase $ssid $wpa_passphrase | grep '^[[:blank:]]*[^[:blank:]#;]' | grep psk | cut -d= -f2-)
sed -i "s/^wpa_psk=.*/wpa_psk=$wpa_psk/" /etc/hostapd.conf
fi
}
}
#
# edit hostapd parameters
#
function wlan_edit ()
{
# select default interfaces if there is more than one
select_interface "default"
dialog --title " Configuration edit " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Basic" \
--no-label "Advanced" --yesno "\n\Z1Basic:\Z0 Change SSID, password and channel\n\n\Z1Advanced:\Z0 Edit /etc/hostapd.conf file" 9 70
if [[ $? = 0 ]]; then
wlan_edit_basic
elif [[ $? = 1 ]]; then
dialog --backtitle "$BACKTITLE" --title " Edit hostapd configuration /etc/hostapd.conf" --no-collapse \
--ok-label "Save" --editbox /etc/hostapd.conf 30 0 2> /etc/hostapd.conf.out
[[ $? = 0 ]] && mv /etc/hostapd.conf.out /etc/hostapd.conf && service hostapd restart
fi
}
#
# here we add wifi exceptions
#
function wlan_exceptions ()
{
reboot_module=false
[[ -n "$(lsmod | grep -w dhd)" && $1 = "on" ]] && \
echo 'options dhd op_mode=2' >/etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
[[ -n "$(lsmod | grep -w dhd)" && $1 = "off" ]] && \
rm /etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
# Cubietruck
[[ -n "$(lsmod | grep -w ap6210)" && $1 = "on" ]] && \
echo 'options ap6210 op_mode=2' >/etc/modprobe.d/ap6210.conf && reboot_module=true
[[ -n "$(lsmod | grep -w ap6210)" && $1 = "off" ]] && \
rm /etc/modprobe.d/ap6210.conf && reboot_module=true
}
#
# here add shaddy wifi adaptors
#
function check_and_warn ()
{
local shaddy=false
# blacklist
[[ "$LINUXFAMILY" == "sun8i" && $BOARD == "orangepizero" ]] && shaddy=true
[[ -n "$(lsmod | grep mt7601u)" ]] && shaddy=true
[[ -n "$(lsmod | grep r8188eu)" ]] && shaddy=true
# blacklist
if [[ "$shaddy" == "true" ]]; then
dialog --title " Warning " --ok-label " Accept and proceed " --msgbox '\nOne of your wireless drivers are on a black list due to poor quality.\n\nAP mode might not be possible!' 9 73
fi
}
#
# search for wlan interfaces and provide a selection menu if there are more than one
#
function get_wlan_interface ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
WLAN_INTERFACES=($(LC_ALL=C nmcli --wait 10 dev status | grep wifi | grep disconnected |awk '{print $1}'))
local LIST=()
for i in "${WLAN_INTERFACES[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 1 ]; then
WIRELESS_ADAPTER=${WLAN_INTERFACES[0]}
else
exec 3>&1
WIRELESS_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select wlan interface" --clear --menu "" $((6+${LIST_LENGTH})) 40 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
function select_interface ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
local ADAPTER=($(nmcli device status | grep ethernet | awk '{ print $1 }' | grep -v lo))
local LIST=()
for i in "${ADAPTER[@]}"
do
local IPADDR=$(LC_ALL=C ip -4 addr show dev ${i[0]} | awk '/inet/ {print $2}' | cut -d'/' -f1)
ADD_SPEED=""
[[ $i == eth* || $i == en* ]] && ADD_SPEED=$(ethtool $i | grep Speed)
[[ $i == wl* ]] && ADD_SPEED=$(LC_ALL=C nmcli -f RATE,DEVICE,ACTIVE dev wifi list | grep $i | grep yes | awk 'NF==4{print $1""$2}NF==1' | sed -e 's/^/ Speed: /' | tail -1)
LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" )
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then
SELECTED_ADAPTER="lo"
elif [ "$LIST_LENGTH" -eq 1 ]; then
SELECTED_ADAPTER=${ADAPTER[0]}
else
exec 3>&1
SELECTED_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title "Select $1 interface" --clear \
--menu "" $((6+${LIST_LENGTH})) 74 14 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
#
# select interface if there is more than one and adjust metric
#
# $1 = default | all
#
function select_default_interface ()
{
ALREADY_DEFINED=$(cat /etc/iptables.ipv4.nat 2> /dev/null | grep "POSTROUTING -o" | tail -1 | awk '{ print $4 }')
if [[ -n "${ALREADY_DEFINED}" ]]; then
DEFAULT_ADAPTER=${ALREADY_DEFINED}
else
IFS=$'\r\n'
GLOBIGNORE='*'
if [[ $1 == "default" ]]; then
local ADAPTER=($(nmcli -t -f DEVICE connection show --active))
else
local ADAPTER=($(nmcli device status | tail -n +2 | awk '{ print $1 }' | grep -v lo))
fi
local LIST=()
for i in "${ADAPTER[@]}"
do
local IPADDR=$(LC_ALL=C ip -4 addr show dev ${i[0]} | awk '/inet/ {print $2}' | cut -d'/' -f1)
ADD_SPEED=""
[[ $i == eth* || $i == en* ]] && ADD_SPEED=$(ethtool $i | grep Speed)
[[ $i == wl* ]] && ADD_SPEED=$(LC_ALL=C nmcli -f RATE,DEVICE,ACTIVE dev wifi list | grep $i | grep yes | awk 'NF==4{print $1""$2}NF==1' | sed -e 's/^/ Speed: /' | tail -1)
if [[ $1 == "default" ]]; then
[[ $IPADDR != "172.24.1.1" && -n $IPADDR ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" )
else
[[ $IPADDR != "172.24.1.1" ]] && LIST+=( "${i[0]//[[:blank:]]/}" "${IPADDR} ${ADD_SPEED}" )
fi
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then
DEFAULT_ADAPTER="lo"
elif [ "$LIST_LENGTH" -eq 1 ]; then
DEFAULT_ADAPTER=${ADAPTER[0]}
else
exec 3>&1
DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select default interface" --clear --menu "" $((6+${LIST_LENGTH})) 74 14 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
fi
# set highest metric to default adaptor
HIGHEST_METRIC=$(nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep $DEFAULT_ADAPTER | sed 's/:.*$//')
# set metric to 50
nmcli connection modify $HIGHEST_METRIC ipv4.route-metric 50 2> /dev/null
METRIC=77
# set others wired
REMAINING=( `nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep ethernet | grep -v $DEFAULT_ADAPTER | sed 's/:.*$//'` )
if [[ ${#REMAINING[@]} -ge 1 ]]; then
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
fi
# set other wireless
METRIC=88
REMAINING=( `nmcli -t -f UUID,TYPE,DEVICE connection show --active | grep wireless | grep -v $DEFAULT_ADAPTER | sed 's/:.*$//'` )
if [[ ${#REMAINING[@]} -ge 1 ]]; then
for i in "${REMAINING[@]}"
do
METRIC=$(( $METRIC + 1 ))
nmcli connection modify ${i} ipv4.route-metric $METRIC
done
fi
# create default metrics file
cat <<-EOF > /etc/NetworkManager/conf.d/orangepi-default-metric.conf
[connection-ethernet-gateway]
match-device=interface-name:$DEFAULT_ADAPTER
ipv4.route-metric=50
[connection-wifi-other]
match-device=type:wifi
ipv4.route-metric=88
[connection-ethernet-other]
match-device=type:ethernet
ipv4.route-metric=77
EOF
}
#
# search and connect to Bluetooth devices
#
function connect_bt_interface ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nDiscovering Bluetooth devices ... " 5 37
BT_INTERFACES=($(hcitool scan | sed '1d'))
local LIST=()
for i in "${BT_INTERFACES[@]}"
do
local a=$(echo ${i[0]//[[:blank:]]/} | sed -e 's/^\(.\{17\}\).*/\1/')
local b=${i[0]//$a/}
local b=$(echo $b | sed -e 's/^[ \t]*//')
LIST+=( "$a" "$b")
done
LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then
BT_ADAPTER=${WLAN_INTERFACES[0]}
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nNo nearby Bluetooth devices were found!" 7 43
else
exec 3>&1
BT_ADAPTER=$(dialog --backtitle "$BACKTITLE" --no-collapse --title "Select interface" \
--clear --menu "" $((6+${LIST_LENGTH})) 50 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
if [[ $BT_ADAPTER != "" ]]; then
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nConnecting to $BT_ADAPTER " 5 35
BT_EXEC=$(
expect -c 'set prompt "#";set address '$BT_ADAPTER';spawn bluetoothctl;expect -re $prompt;send "disconnect $address\r";
sleep 1;send "remove $address\r";sleep 1;expect -re $prompt;send "scan on\r";sleep 8;send "scan off\r";
expect "Controller";send "trust $address\r";sleep 2;send "pair $address\r";sleep 2;send "connect $address\r";
send_user "\nShould be paired now.\r";sleep 2;send "quit\r";expect eof')
echo "$BT_EXEC" > /tmp/bt-connect-debug.log
if [[ $(echo "$BT_EXEC" | grep "Connection successful" ) != "" ]]; then
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nYour device is ready to use!" 7 32
else
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nError connecting. Try again!" 7 32
fi
fi
fi
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,439 @@
#!/bin/bash
#
# Copyright (c) 2018 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
# Functions:
# submenu_settings
# submenu_networking
# submenu_personal
# submenu_software
#
# system settings
#
function submenu_settings ()
{
unset main
while true; do
LIST=()
DIALOG_CANCEL=1
DIALOG_ESC=255
# detect desktop
check_desktop
# check update status of BSP packages
local mark=$(apt-mark showhold | egrep "linux|orangepi")
# check if eMMC/SD is on the system
if [[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent 2> /dev/null) == mmcblk* \
&& -f /usr/sbin/nand-sata-install ]]; then
LIST+=( "Install" "Install to/update boot loader" )
fi
# orangepi specific function
if [[ -f /etc/orangepi-release ]]; then
if [[ -n "${mark}" ]]; then
:
#LIST+=( "Defreeze" "Enable Orange Pi upgrades " )
else
:
#LIST+=( "Freeze" "Disable Orange Pi upgrades " )
fi
fi
# orangepi specific function, when upgrades are enabled
if [[ -z ${mark} ]]; then
[[ -f /etc/apt/sources.list.d/orangepi.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/orangepi.list) ]] \
&& LIST+=( "Nightly" "Switch to nightly automated builds" )
[[ -f /etc/apt/sources.list.d/orangepi.list ]] && [[ -n $(grep -w beta /etc/apt/sources.list.d/orangepi.list) ]] \
&& LIST+=( "Stable" "Switch to stable builds" )
fi
[[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" )
[[ -f /boot/orangepiEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" )
[[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" )
if [[ -f /etc/default/cpufrequtils ]]; then
LIST+=( "CPU" "Set CPU speed and governor" )
fi
AVAHIDSTATUS=$(service avahi-daemon status 2> /dev/null | grep -w active | grep -w running)
if [[ -n "$AVAHIDSTATUS" ]]; then
LIST+=( "Avahi" "Disable system announce in the network" )
else
LIST+=( "Avahi" "Announce system in the network" )
fi
[[ -d ${OVERLAYDIR} ]] && \
LIST+=( "Hardware" "Toggle hardware configuration: UART, I2C, etc." )
[[ "$LINUXFAMILY" = cubox && "$BRANCH" = "next" ]] && LIST+=( "DTB" "Switch board .dtb configuration" )
# this is avaliable only in kernel higher than 4.10
testvercomp "$(uname -r | sed 's/-.*//')" "4.10.0" ">"
[[ "$LINUXFAMILY" = odroidxu4 && $? == 0 ]] && LIST+=( "DTB" "Select optimised board configuration" )
[[ -f /usr/bin/bin2fex && "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" ]] && LIST+=( "Fexedit" "Board (fex) settings editor" )
[[ -z ${mark} ]] && [[ -f /etc/apt/sources.list.d/orangepi.list ]] && LIST+=( "Other" "Switch to other kernels" )
LIST+=( "SSH" "Reconfigure SSH daemon" )
LIST+=( "Firmware" "Run apt update & apt upgrade" )
if [[ "$SHELL" != "/bin/bash" ]]; then
LIST+=( "BASH" "Revert to stock BASH shell" )
else
LIST+=( "ZSH" "Install ZSH with plugins and tmux" )
fi
[[ "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" && \
-n $(bin2fex </boot/script.bin 2>/dev/null | grep -w "hdmi_used = 1") ]] && LIST+=( "Display" "Set the display resolution" )
[[ "$LINUXFAMILY" = odroidc* || "$LINUXFAMILY" = odroidn2 && "$BRANCH" = "default" ]] && LIST+=( "Display" "Set the display resolution" )
# desktop
if [[ -n $DISPLAY_MANAGER ]]; then
LIST+=( "Desktop" "Disable desktop or change login type" )
else
if [[ -n $DESKTOP_INSTALLED ]]; then
LIST+=( "Desktop" "Enable desktop" )
else
:
#LIST+=( "Default" "Install desktop with browser and extras" )
fi
fi
# overlayroot
if [[ "$DISTRO" =~ "Ubuntu"|"Debian" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]]; then
#if [ -n "$(mount | grep -w tmpfs-root)" ]; then
# :
# #LIST+=( "Overlayroot" "Disable virtual read-only root filesystem" )
#else
# :
# #LIST+=( "Overlayroot" "Enable virtual read-only root filesystem" )
#fi
LIST+=( "Overlayroot" "Enable or disable a overlay filesystem." )
fi
# count number of menu items to adjust window size
LISTLENGTH="$((6+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
temp_rc=$(mktemp)
if [[ -n ${mark} || -n $(grep -w beta /etc/apt/sources.list.d/orangepi.list 2> /dev/null) ]]; then
cat <<-'EOF' > $temp_rc
dialog_color = (RED,WHITE,OFF)
screen_color = (WHITE,RED,ON)
tag_color = (RED,WHITE,ON)
item_selected_color = (WHITE,RED,ON)
tag_selected_color = (WHITE,RED,ON)
tag_key_selected_color = (WHITE,RED,ON)
EOF
[[ -n ${mark} ]] && local sys_title=" Warning - firmware packages frozen"
[[ -n $(grep -w beta /etc/apt/sources.list.d/orangepi.list 2> /dev/null) ]] && \
local sys_title=" Warning - attached to beta repository"
[[ -n ${mark} && -n $(grep -w beta /etc/apt/sources.list.d/orangepi.list 2> /dev/null) ]] && \
sys_title=" Warning - frozen & attached to beta repository"
else
local sys_title=" System settings "
echo > $temp_rc
fi
if [[ -z $selection ]]; then
exec 3>&1
selection=$(DIALOGRC=$temp_rc dialog --colors --backtitle "$BACKTITLE" --title " $sys_title " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 0 $BOXLENGTH \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
done
}
#
# menu for networking
#
function submenu_networking ()
{
# select default interface if there is more than one connected
#select_interface "default"
unset main
while true; do
LIST=()
DIALOG_CANCEL=1
DIALOG_ESC=255
# check if we have some LTE modems
for i in $(lsusb | awk '{print $6}'); do lte "$i"; done;
# edit ip
LIST+=( "IP" "Select dynamic or edit static IP address" )
# hostapd
HOSTAPDBRIDGE=$(cat /etc/hostapd.conf 2> /dev/null | grep -w "^bridge=br0")
HOSTAPDSTATUS=$(service hostapd status 2> /dev/null | grep -w active | grep -w running)
if [[ -n "$HOSTAPDSTATUS" ]]; then
HOSTAPDINFO=$(hostapd_cli get_config 2> /dev/null | grep ^ssid | sed 's/ssid=//g')
HOSTAPDCLIENTS=$(hostapd_cli all_sta 2> /dev/null | grep connected_time | wc -l)
LIST+=( "Hotspot" "Manage active wireless access point" )
else
:
#[[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -w disconnected) ]] && \
#LIST+=( "Hotspot" "Create WiFi access point" )
fi
# toggle IPv6
if [[ $(cat /proc/sys/net/ipv6/conf/all/disable_ipv6) == 1 ]]; then
LIST+=( "IPV6" "Enable IPv6 for APT and system" )
else
LIST+=( "IPV6" "Disable IPv6 for APT and system" )
fi
# network throughput test
if check_if_installed iperf3; then
if pgrep -x "iperf3" > /dev/null
then
LIST+=( "Iperf3" "Disable network throughput tests daemon" )
else
LIST+=( "Iperf3" "Enable network throughput tests daemon" )
fi
fi
if [[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -v unavailable | grep -v unmanaged) ]]; then
LIST+=( "WiFi" "Manage wireless networking" )
else
LIST+=( "Clear" "Clear possible blocked interfaces" )
fi
if [[ -n $LTE_MODEM ]]; then
# apply udev rules
initialize_lte
LIST+=( "LTE" "$LTE_MODEM" )
fi
check_if_installed lirc && LIST+=( "Remove IR" "Remove IR support" ) || LIST+=( "IR" "Install IR support" )
if check_if_installed bluetooth then ; then
LIST+=( "BT remove" "Remove Bluetooth support" )
if [[ -n $(service bluetooth status | grep -w active | grep -w running) ]]; then
[[ $(hcitool dev | sed '1d') != "" ]] && LIST+=( "BT discover" "Discover and connect Bluetooth devices" )
fi
else
LIST+=( "BT install" "Install Bluetooth support" )
fi
[[ -d /usr/local/vpnclient ]] && LIST+=( "VPN" "Manage Softether VPN client" ) && VPNSERVERIP=$(/usr/local/vpnclient/vpncmd /client localhost /cmd accountlist | grep "VPN Server" |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | head -1)
LIST+=( "Advanced" "Edit /etc/network/interfaces" )
[[ $(ls -1 /etc/NetworkManager/system-connections 2> /dev/null) ]] && \
LIST+=( "Forget" "Disconnect and forget all wireless connections" )
# count number of menu items to adjust window size
LISTLENGTH="$((12+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
WIFICONNECTED=$(LC_ALL=C nmcli -f NAME,TYPE connection show --active 2> /dev/null | grep wireless | awk 'NF{NF-=1};1')
local disclaimer=""
local ipadd=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
if [[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep $DEFAULT_ADAPTER | grep connected) ]]; then
local ifup="\nIP ($DEFAULT_ADAPTER) via Network Manager: \Z1${ipadd}\n\Z0 "
else
if [[ -n $(service systemd-networkd status | grep -w active | grep -w running) ]]; then
local ifup="\nIP ($DEFAULT_ADAPTER) via systemd-networkd: \Z1${ipadd}\n\Z0 "
else
local ifup="\nIP ($DEFAULT_ADAPTER) via IFUPDOWN: \Z1${ipadd}\n\Z0 "
fi
fi
disclaimer="$ifup"
if [[ -n $WIFICONNECTED ]]; then
LISTLENGTH=$((LISTLENGTH+2))
local connected="\n\Z0Connected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
disclaimer=$disclaimer"$connected"
fi
if [[ -n $VPNSERVERIP ]]; then
local vpnserverip="\n\Z0Connected to VPN server: \Z1${VPNSERVERIP}\n\Z0 "
disclaimer=$disclaimer"$vpnserverip"
LISTLENGTH=$((LISTLENGTH+2))
fi
if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
LISTLENGTH=$((LISTLENGTH+2))
chpid=$(dmesg | grep $(grep ^interface /etc/hostapd.conf | sed 's/interface=//g') | head -1 | sed 's/\[.*\]//g' | awk '{print $1}')
disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:";
if [[ `grep ^hw_mode=a /etc/hostapd.conf` ]]; then local band="5Ghz"; else band="2.4Ghz"; fi
if [[ `grep ^ieee80211n /etc/hostapd.conf` ]]; then local type="N"; fi
if [[ `grep ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi
disclaimer=$disclaimer$" \Z1${band} ${type}\Z0"
[[ ! "$chpid" =~ .*IPv6.* ]] && disclaimer=$disclaimer$"\n\nChip: \Z1${chpid}\Z0";
if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
if [[ ! "$chpid" =~ .*IPv6.* ]]; then LISTLENGTH=$((LISTLENGTH+2)); fi
disclaimer=$disclaimer$"\n";
fi
disclaimer=$disclaimer"\n\Z1Note\Zn: This tool can be successful only when drivers are configured properly. If auto-detection fails, you are on your own.\n "
if [[ -z $selection ]]; then
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
--cancel-label "Back" --menu "${disclaimer}" $LISTLENGTH 70 $BOXLENGTH \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
done
}
#
# personal
#
function submenu_personal ()
{
unset main
while true; do
LIST=()
LIST+=( "Timezone" "Change timezone \Z5($(LC_ALL=C timedatectl | grep zone | awk '{$1=$1;print}' | sed "s/Time zone: //"))\Z0" )
LIST+=( "Locales" "Reconfigure language \Z5($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1))\Z0 and character set" )
LIST+=( "Keyboard" "Change console keyboard layout (\Z5$(cat /etc/default/keyboard | grep XKBLAYOUT | grep -o '".*"' | sed 's/"//g')\Z0)")
LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" )
LIST+=( "Welcome" "Toggle welcome screen items" )
# count number of menu items to adjust window sizee
LISTLENGTH="$((6+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
exec 3>&1
selection=$(dialog --colors --backtitle "$BACKTITLE" --title "Personal settings" --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
# run main function
jobs "$selection"
done
}
#
# software
#
function submenu_software ()
{
unset main
while true; do
# detect desktop
check_desktop
LIST=()
[[ -f /usr/bin/softy || -f softy ]] && LIST+=( "Softy" "3rd party applications installer" )
[[ -f /usr/bin/h3consumption && "$LINUXFAMILY" = "sun8i" && "$BRANCH" = "default" ]] && \
LIST+=( "Consumption" "Control board consumption" )
[[ -f /usr/bin/orangepimonitor ]] && LIST+=( "Monitor" "Simple CLI board monitoring" )
LIST+=( "Benchmarking" "sbc-bench board benchmarking" )
[[ -f /usr/bin/orangepimonitor ]] && LIST+=( "Diagnostics" "Send diagnostics" )
#if [[ -n $(dpkg -l | grep linux-headers) ]]; then LIST+=( "Headers_remove" "kernel headers" ); else \
#LIST+=( "Headers_install" "kernel headers" ); fi
SOURCE_PKG_LIST=$(apt-cache --names-only search ^linux-source-* | awk '{ print $1 }' | grep -w ${BRANCH}-${LINUXFAMILY} | tail -n 5)
if [[ -n $SOURCE_PKG_LIST ]]; then
:
#LIST+=( "Source_install" "kernel source" )
fi
SOURCE_PKG_LIST_INSTALLED=$(find /usr/src -maxdepth 1 -name "linux-source*")
if [[ -n $SOURCE_PKG_LIST_INSTALLED ]]; then
:
#LIST+=( "Source_remove" "kernel source" );
fi
if [[ -f /etc/orangepi.txt ]]; then
if [[ -n $(dpkg -l | grep -w "orangepi-firmware-full ") ]]; then
:
#LIST+=( "Mini" "Install mini firmware package" );
else
:
#LIST+=( "Full" "Install full firmware package" );
fi
fi
if [[ -n $DISPLAY_MANAGER ]]; then
if [[ $(service xrdp status 2> /dev/null | grep -w active) ]]; then
LIST+=( "RDP" "Disable remote desktop access from Windows" )
else
LIST+=( "RDP" "Enable remote desktop access from Windows" )
fi
if ! check_if_installed thunderbird ; then
LIST+=( "Thunderbird" "Install full featured email client" )
else
LIST+=( "Thunderbird" "Remove full featured email client" )
fi
if ! check_if_installed gimp ; then
LIST+=( "Gimp" "Install photo manipulation tool" )
else
LIST+=( "Gimp" "Remove photo manipulation tool" )
fi
if ! check_if_installed libreoffice-writer ; then
LIST+=( "Writer" "Libreoffice: Writer only" )
LIST+=( "Suite" "Libreoffice: Full suite" )
else
if ! check_if_installed libreoffice-base ; then
LIST+=( "Suite" "Libreoffice: Full suite" )
LIST+=( "Libre" "Remove Libre office packages" )
else
LIST+=( "Libre" "Remove Libre office packages" )
fi
fi
fi
# count number of menu items to adjust window sizee
LISTLENGTH="$((6+${#LIST[@]}/2))"
BOXLENGTH=${#LIST[@]}
if [[ -z $selection ]]; then
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
fi
# run main function
jobs "$selection"
done
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
[global]
workgroup = SMBGROUP
server string = %h server
hosts allow = SUBNET
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
load printers = yes
printing = cups
printcap name = cups
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
public = yes
guest ok = yes
writable = no
printable = yes
printer admin = SMBUSER
[print$]
comment = Printer Drivers
path = /etc/samba/drivers
browseable = yes
guest ok = no
read only = yes
write list = SMBUSER
[ext]
comment = Storage
path = /ext
writable = yes
public = no
valid users = SMBUSER
force create mode = 0777

View File

@@ -0,0 +1,55 @@
#!/bin/bash
dflag=
vflag=
cflag=
if (( $# < 1 ))
then
### URL of your XML file
wget -qO - "http://xml.tv.data"
exit 0
fi
for arg
do
delim=""
case "$arg" in
#translate --gnu-long-options to -g (short options)
--description) args="${args}-d ";;
--version) args="${args}-v ";;
--capabilities) args="${args}-c ";;
#pass through anything else
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} ";;
esac
done
#Reset the positional parameters to the short options
eval set -- $args
while getopts "dvc" option
do
case $option in
d) dflag=1;;
v) vflag=1;;
c) cflag=1;;
\?) printf "unknown option: -%s\n" $OPTARG
printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0)
exit 2
;;
esac >&2
done
if [ "$dflag" ]
then
printf "tv_grag_file is a simple grabber that just read the ~/.xmltv/tv_grab_file.xmltv file\n"
fi
if [ "$vflag" ]
then
printf "0.1\n"
fi
if [ "$cflag" ]
then
printf "baseline\n"
fi
exit 0

View File

@@ -0,0 +1 @@
debian-software