From 42c7d2aa17f1382d2e8d01c616752f87b1c7331f Mon Sep 17 00:00:00 2001 From: gfdgd-xi <3025613752@qq.com> Date: Sun, 25 Jun 2023 12:15:20 +0800 Subject: [PATCH] first commit --- init.sh | 25 +++++++++++++++++++++++++ install-deb.sh | 3 +++ load-env-root.sh | 12 ++++++++++++ load-env-user-root.sh | 13 +++++++++++++ run-filemanager.sh | 2 ++ run-root.sh | 10 ++++++++++ run-terminal.sh | 2 ++ run.sh | 10 ++++++++++ 8 files changed, 77 insertions(+) create mode 100755 init.sh create mode 100755 install-deb.sh create mode 100755 load-env-root.sh create mode 100755 load-env-user-root.sh create mode 100755 run-filemanager.sh create mode 100755 run-root.sh create mode 100755 run-terminal.sh create mode 100755 run.sh diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..913aac8 --- /dev/null +++ b/init.sh @@ -0,0 +1,25 @@ +#!/bin/bash +chrootEnvPath=/opt/new-system-env +if [[ ! -f /usr/bin/pardus-chroot ]]; then + echo 请安装 pardus-chroot 后再试 + exit 1 +fi +if [[ ! -d $chrootEnvPath ]]; then + echo Chroot 环境不存在,请部署环境后再试 + exit 1 +fi +echo aa > /tmp/env-$USER.txt +if [[ ! -f $chrootEnvPath/tmp/env-$USER.txt ]]; then + echo 未挂载目录,立即挂载 + sudo ./load-env-root.sh +fi +#user=`whoami` +if [[ ! -f $chrootEnvPath/user/$USER ]]; then + ./load-env-user-root.sh + if [[ $? != 0 ]]; then + echo Create User Error! + exit 1 + fi + sudo mkdir $chrootEnvPath/user/ -p #$USER + sudo touch $chrootEnvPath/user/$USER +fi \ No newline at end of file diff --git a/install-deb.sh b/install-deb.sh new file mode 100755 index 0000000..e23fd83 --- /dev/null +++ b/install-deb.sh @@ -0,0 +1,3 @@ +#!/bin/bash +./run-root.sh apt update +./run-root.sh apt install "$1" \ No newline at end of file diff --git a/load-env-root.sh b/load-env-root.sh new file mode 100755 index 0000000..ac979fb --- /dev/null +++ b/load-env-root.sh @@ -0,0 +1,12 @@ +#!/bin/bash +if [[ `whoami` != "root" ]]; then + echo 请使用 root 权限运行 + exit 1 +fi +xhost + +chrootEnvPath=/opt/new-system-env +pardus-chroot $chrootEnvPath +rm $chrootEnvPath/etc/resolv.conf +cp /etc/resolv.conf $chrootEnvPath/etc/resolv.conf +mount --bind /home $chrootEnvPath/home +mount --bind /root $chrootEnvPath/root \ No newline at end of file diff --git a/load-env-user-root.sh b/load-env-user-root.sh new file mode 100755 index 0000000..c6adbf8 --- /dev/null +++ b/load-env-user-root.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +chrootEnvPath=/opt/new-system-env +zenity --info --text=请输入需要设置的密码 --no-wrap +firstPWD=`zenity --password` +zenity --info --text=请再输入一次相同的密码 --no-wrap +secondPWD=`zenity --password` +if [[ $firstPWD != $secondPWD ]]; then + zenity --error --text=密码不相同,无法继续 --no-wrap + exit 1 +fi +echo -e "$firstPWD\n$firstPWD\n\n\n\n\n\nY\n" | ./run-root.sh adduser `whoami` +./run-root.sh bash -c "echo $USER >> /etc/sudo" diff --git a/run-filemanager.sh b/run-filemanager.sh new file mode 100755 index 0000000..96aab08 --- /dev/null +++ b/run-filemanager.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./run.sh dolphin \ No newline at end of file diff --git a/run-root.sh b/run-root.sh new file mode 100755 index 0000000..bab188e --- /dev/null +++ b/run-root.sh @@ -0,0 +1,10 @@ +#!/bin/bash +chrootEnvPath=/opt/new-system-env +#if [[ `whoami` != "root" ]]; then +# echo 请使用 root 权限运行 +# exit 1 +#fi +command="$@" +#echo $command +sudo chroot $chrootEnvPath "$@" +#echo $@ \ No newline at end of file diff --git a/run-terminal.sh b/run-terminal.sh new file mode 100755 index 0000000..21cdcb3 --- /dev/null +++ b/run-terminal.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./run.sh xfce4-terminal \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..8cad95d --- /dev/null +++ b/run.sh @@ -0,0 +1,10 @@ +#!/bin/bash +chrootEnvPath=/opt/new-system-env +#if [[ `whoami` != "root" ]]; then +# echo 请使用 root 权限运行 +# exit 1 +#fi +command="$@" +#echo $command +sudo chroot $chrootEnvPath sudo -u $USER bash -c "$command" +#echo $@ \ No newline at end of file