OSDN Git Service

sudoを消して、最初にRootチェックを追加 delete-sudo
authorhayao <shun819.mail@gmail.com>
Sat, 20 Apr 2019 16:40:41 +0000 (01:40 +0900)
committerhayao <shun819.mail@gmail.com>
Sat, 20 Apr 2019 16:40:44 +0000 (01:40 +0900)
NonFreeRepo/tools/addrepo.sh

index 09a26d2..7702b49 100755 (executable)
@@ -1,6 +1,15 @@
 #!/bin/bash
+
+
+#RootChesk
+if [[ ! $UID = 0 ]];
+    echo "You need root permission."
+    exit 1
+fi
+
+
 addrepo(){
-    sudo sh -c "echo 'deb "$repo" "$channel" "$branch"' > /etc/apt/sources.list.d/'$group'.list"
+    sh -c "echo 'deb "$repo" "$channel" "$branch"' > /etc/apt/sources.list.d/'$group'.list"
     wget -O - "$key" |sudo apt-key add -
 }
 ADD_LIST=("$@")
@@ -37,8 +46,8 @@ do
               pkgname=$7
                          cd /tmp
                          curl "$key" | gpg --dearmor > ${key##*/}
-                         sudo install -o root -g root -m 644 ${key##*/} /etc/apt/trusted.gpg.d/
-                         sudo sh -c "echo 'deb "$repo" "$channel" "$branch"' > /etc/apt/sources.list.d/'$group'.list"
+                         install -o root -g root -m 644 ${key##*/} /etc/apt/trusted.gpg.d/
+                         sh -c "echo 'deb "$repo" "$channel" "$branch"' > /etc/apt/sources.list.d/'$group'.list"
               $((i++))
               shift 7;;
       esac;shift
@@ -48,15 +57,16 @@ done
               repo=$1
               pkgname=$2
               INSTALL_LIST=("$INSTALL_LIST[@]" "$pkgname")
-              sudo add-apt-repository "$repo"
+              add-apt-repository "$repo"
               $((i++))
               shift 2
           fi
 done
 
-sudo apt update
+apt-get update
 
 for install in ${INSTALL_LIST[@]}; do
-       sudo apt install $install
+       apt-get install $install
 done
-sudo apt autoremove
+apt-get -yf install
+apt-get -y autoremove